typescript 4.8.0-dev.20220724 → 4.8.0-dev.20220727
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/cs/diagnosticMessages.generated.json +2 -0
- package/lib/de/diagnosticMessages.generated.json +2 -0
- package/lib/es/diagnosticMessages.generated.json +2 -0
- package/lib/fr/diagnosticMessages.generated.json +2 -0
- package/lib/it/diagnosticMessages.generated.json +2 -0
- package/lib/ja/diagnosticMessages.generated.json +2 -0
- package/lib/ko/diagnosticMessages.generated.json +2 -0
- package/lib/lib.es2015.proxy.d.ts +91 -2
- package/lib/pl/diagnosticMessages.generated.json +2 -0
- package/lib/pt-br/diagnosticMessages.generated.json +2 -0
- package/lib/ru/diagnosticMessages.generated.json +2 -0
- package/lib/tr/diagnosticMessages.generated.json +2 -0
- package/lib/tsc.js +25 -26
- package/lib/tsserver.js +149 -43
- package/lib/tsserverlibrary.js +149 -43
- package/lib/typescript.js +149 -43
- package/lib/typescriptServices.js +149 -43
- package/lib/typingsInstaller.js +33 -30
- package/lib/zh-cn/diagnosticMessages.generated.json +2 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +2 -0
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220727";
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -8577,6 +8577,7 @@ var ts;
|
|
|
8577
8577
|
Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
|
|
8578
8578
|
auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
|
|
8579
8579
|
An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
|
|
8580
|
+
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8580
8581
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8581
8582
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8582
8583
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -33316,7 +33317,9 @@ var ts;
|
|
|
33316
33317
|
case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33317
33318
|
case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33318
33319
|
case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33319
|
-
|
|
33320
|
+
case 24 /* AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
|
|
33321
|
+
case 25 /* Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
|
|
33322
|
+
default: ts.Debug.assertNever(context);
|
|
33320
33323
|
}
|
|
33321
33324
|
}
|
|
33322
33325
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
@@ -33757,7 +33760,7 @@ var ts;
|
|
|
33757
33760
|
// FormalParameter [Yield,Await]:
|
|
33758
33761
|
// BindingElement[?Yield,?Await]
|
|
33759
33762
|
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
|
33760
|
-
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators
|
|
33763
|
+
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
|
|
33761
33764
|
if (token() === 108 /* ThisKeyword */) {
|
|
33762
33765
|
var node_1 = factory.createParameterDeclaration(decorators,
|
|
33763
33766
|
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
|
@@ -67948,37 +67951,33 @@ var ts;
|
|
|
67948
67951
|
var commonBaseType;
|
|
67949
67952
|
for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
|
|
67950
67953
|
var t = types_13[_i];
|
|
67951
|
-
|
|
67952
|
-
|
|
67953
|
-
commonBaseType = baseType;
|
|
67954
|
-
|
|
67955
|
-
|
|
67956
|
-
|
|
67954
|
+
if (!(t.flags & 131072 /* Never */)) {
|
|
67955
|
+
var baseType = getBaseTypeOfLiteralType(t);
|
|
67956
|
+
commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
|
|
67957
|
+
if (baseType === t || baseType !== commonBaseType) {
|
|
67958
|
+
return false;
|
|
67959
|
+
}
|
|
67957
67960
|
}
|
|
67958
67961
|
}
|
|
67959
67962
|
return true;
|
|
67960
67963
|
}
|
|
67961
|
-
|
|
67962
|
-
|
|
67963
|
-
// right is a supertype.
|
|
67964
|
-
function getSupertypeOrUnion(types) {
|
|
67965
|
-
if (types.length === 1) {
|
|
67966
|
-
return types[0];
|
|
67967
|
-
}
|
|
67968
|
-
return literalTypesWithSameBaseType(types) ?
|
|
67969
|
-
getUnionType(types) :
|
|
67970
|
-
ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
67964
|
+
function getCombinedTypeFlags(types) {
|
|
67965
|
+
return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
|
|
67971
67966
|
}
|
|
67972
67967
|
function getCommonSupertype(types) {
|
|
67973
|
-
if (
|
|
67974
|
-
return
|
|
67975
|
-
}
|
|
67976
|
-
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
67977
|
-
if (primaryTypes.length) {
|
|
67978
|
-
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
67979
|
-
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
67968
|
+
if (types.length === 1) {
|
|
67969
|
+
return types[0];
|
|
67980
67970
|
}
|
|
67981
|
-
|
|
67971
|
+
// Remove nullable types from each of the candidates.
|
|
67972
|
+
var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* Nullable */); }); }) : types;
|
|
67973
|
+
// When the candidate types are all literal types with the same base type, return a union
|
|
67974
|
+
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
|
67975
|
+
// right is a supertype.
|
|
67976
|
+
var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
|
|
67977
|
+
getUnionType(primaryTypes) :
|
|
67978
|
+
ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
67979
|
+
// Add any nullable types that occurred in the candidates back to the result.
|
|
67980
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
67982
67981
|
}
|
|
67983
67982
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
67984
67983
|
function getCommonSubtype(types) {
|
|
@@ -71952,8 +71951,12 @@ var ts;
|
|
|
71952
71951
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
71953
71952
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
71954
71953
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
71955
|
-
// specific of the two.
|
|
71956
|
-
|
|
71954
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
71955
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
71956
|
+
// prototype object types.
|
|
71957
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
71958
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
71959
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
71957
71960
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
71958
71961
|
// are related by constraint.
|
|
71959
71962
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -90572,7 +90575,7 @@ var ts;
|
|
|
90572
90575
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90573
90576
|
case 197 /* NamedTupleMember */:
|
|
90574
90577
|
ts.Debug.type(node);
|
|
90575
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90578
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90576
90579
|
case 191 /* ParenthesizedType */:
|
|
90577
90580
|
ts.Debug.type(node);
|
|
90578
90581
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -155393,8 +155396,7 @@ var ts;
|
|
|
155393
155396
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155394
155397
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155395
155398
|
if (info) {
|
|
155396
|
-
|
|
155397
|
-
if (ts.addToSeen(seen, id)) {
|
|
155399
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
155398
155400
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
155399
155401
|
}
|
|
155400
155402
|
}
|
|
@@ -159362,21 +159364,16 @@ var ts;
|
|
|
159362
159364
|
var names = ts.map(args, function (arg) {
|
|
159363
159365
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159364
159366
|
});
|
|
159365
|
-
var
|
|
159366
|
-
|
|
159367
|
-
});
|
|
159367
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159368
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159368
159369
|
var modifiers = modifierFlags
|
|
159369
159370
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159370
159371
|
: undefined;
|
|
159371
159372
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159372
159373
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159373
159374
|
: undefined;
|
|
159374
|
-
var typeParameters = isJs
|
|
159375
|
-
|
|
159376
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159377
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159378
|
-
});
|
|
159379
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159375
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159376
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159380
159377
|
var type = isJs || contextualType === undefined
|
|
159381
159378
|
? undefined
|
|
159382
159379
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -159394,6 +159391,23 @@ var ts;
|
|
|
159394
159391
|
}
|
|
159395
159392
|
}
|
|
159396
159393
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
159394
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
159395
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
159396
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
159397
|
+
if (typeArguments) {
|
|
159398
|
+
var typeArgumentsWithNewTypes = typeArguments.filter(function (typeArgument) { return !argumentTypeParameters.some(function (pair) { var _a; return checker.getTypeAtLocation(typeArgument) === ((_a = pair[1]) === null || _a === void 0 ? void 0 : _a.argumentType); }); });
|
|
159399
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
159400
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
159401
|
+
usedNames.add(createTypeParameterName(i));
|
|
159402
|
+
}
|
|
159403
|
+
}
|
|
159404
|
+
return ts.map(ts.arrayFrom(usedNames.values()), function (usedName) { var _a; return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, (_a = constraintsByName.get(usedName)) === null || _a === void 0 ? void 0 : _a.constraint); });
|
|
159405
|
+
}
|
|
159406
|
+
function createTypeParameterName(index) {
|
|
159407
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
159408
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
159409
|
+
: "T" + index;
|
|
159410
|
+
}
|
|
159397
159411
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
159398
159412
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
159399
159413
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -159407,15 +159421,107 @@ var ts;
|
|
|
159407
159421
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
159408
159422
|
}
|
|
159409
159423
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
159424
|
+
function typeContainsTypeParameter(type) {
|
|
159425
|
+
if (type.isUnionOrIntersection()) {
|
|
159426
|
+
return type.types.some(typeContainsTypeParameter);
|
|
159427
|
+
}
|
|
159428
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
159429
|
+
}
|
|
159430
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
159431
|
+
// Types to be used as the types of the parameters in the new function
|
|
159432
|
+
// E.g. from this source:
|
|
159433
|
+
// added("", 0)
|
|
159434
|
+
// The value will look like:
|
|
159435
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
159436
|
+
// And in the output function will generate:
|
|
159437
|
+
// function added(a: string, b: number) { ... }
|
|
159438
|
+
var argumentTypeNodes = [];
|
|
159439
|
+
// Names of type parameters provided as arguments to the call
|
|
159440
|
+
// E.g. from this source:
|
|
159441
|
+
// added<T, U>(value);
|
|
159442
|
+
// The value will look like:
|
|
159443
|
+
// [
|
|
159444
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
159445
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
159446
|
+
// ]
|
|
159447
|
+
// And in the output function will generate:
|
|
159448
|
+
// function added<T, U>() { ... }
|
|
159449
|
+
var argumentTypeParameters = new ts.Map();
|
|
159450
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
159451
|
+
var instanceType = instanceTypes[i];
|
|
159452
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
159453
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
159454
|
+
// E.g. from this source:
|
|
159455
|
+
// function existing<T, U>(value: T | U & string) {
|
|
159456
|
+
// added/*1*/(value);
|
|
159457
|
+
// We don't want to output this:
|
|
159458
|
+
// function added<T>(value: T | U & string) { ... }
|
|
159459
|
+
// We instead want to output:
|
|
159460
|
+
// function added<T>(value: T) { ... }
|
|
159461
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
159462
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
159463
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
159464
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
159465
|
+
continue;
|
|
159466
|
+
}
|
|
159467
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
159468
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
159469
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
159470
|
+
if (!argumentTypeNode) {
|
|
159471
|
+
continue;
|
|
159472
|
+
}
|
|
159473
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
159474
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
159475
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
159476
|
+
// remember that constraint for when we create the new type parameter
|
|
159477
|
+
// E.g. from this source:
|
|
159478
|
+
// function existing<T extends string>(value: T) {
|
|
159479
|
+
// added/*1*/(value);
|
|
159480
|
+
// We don't want to output this:
|
|
159481
|
+
// function added<T>(value: T) { ... }
|
|
159482
|
+
// We instead want to output:
|
|
159483
|
+
// function added<T extends string>(value: T) { ... }
|
|
159484
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
159485
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
159486
|
+
: undefined;
|
|
159487
|
+
if (argumentTypeParameter) {
|
|
159488
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
159489
|
+
}
|
|
159490
|
+
}
|
|
159491
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
159492
|
+
}
|
|
159493
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
159494
|
+
function isAnonymousObjectConstraintType(type) {
|
|
159495
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
159496
|
+
}
|
|
159497
|
+
function getFirstTypeParameterName(type) {
|
|
159498
|
+
var _a;
|
|
159499
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
159500
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
159501
|
+
var subType = _b[_i];
|
|
159502
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
159503
|
+
if (subTypeName) {
|
|
159504
|
+
return subTypeName;
|
|
159505
|
+
}
|
|
159506
|
+
}
|
|
159507
|
+
}
|
|
159508
|
+
return type.flags & 262144 /* TypeParameter */
|
|
159509
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
159510
|
+
: undefined;
|
|
159511
|
+
}
|
|
159410
159512
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
159411
159513
|
var parameters = [];
|
|
159514
|
+
var parameterNameCounts = new ts.Map();
|
|
159412
159515
|
for (var i = 0; i < argCount; i++) {
|
|
159516
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
159517
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
159518
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
159413
159519
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
159414
159520
|
/*modifiers*/ undefined,
|
|
159415
159521
|
/*dotDotDotToken*/ undefined,
|
|
159416
|
-
/*name*/
|
|
159522
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
159417
159523
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
159418
|
-
/*type*/ inJs ? undefined : types
|
|
159524
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
159419
159525
|
/*initializer*/ undefined);
|
|
159420
159526
|
parameters.push(newParameter);
|
|
159421
159527
|
}
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -303,7 +303,7 @@ var ts;
|
|
|
303
303
|
// The following is baselined as a literal template type without intervention
|
|
304
304
|
/** The version of the TypeScript compiler release */
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
306
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220727";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -8771,6 +8771,7 @@ var ts;
|
|
|
8771
8771
|
Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
|
|
8772
8772
|
auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
|
|
8773
8773
|
An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
|
|
8774
|
+
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8774
8775
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8775
8776
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8776
8777
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -33510,7 +33511,9 @@ var ts;
|
|
|
33510
33511
|
case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33511
33512
|
case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33512
33513
|
case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33513
|
-
|
|
33514
|
+
case 24 /* AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
|
|
33515
|
+
case 25 /* Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
|
|
33516
|
+
default: ts.Debug.assertNever(context);
|
|
33514
33517
|
}
|
|
33515
33518
|
}
|
|
33516
33519
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
@@ -33951,7 +33954,7 @@ var ts;
|
|
|
33951
33954
|
// FormalParameter [Yield,Await]:
|
|
33952
33955
|
// BindingElement[?Yield,?Await]
|
|
33953
33956
|
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
|
33954
|
-
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators
|
|
33957
|
+
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
|
|
33955
33958
|
if (token() === 108 /* ThisKeyword */) {
|
|
33956
33959
|
var node_1 = factory.createParameterDeclaration(decorators,
|
|
33957
33960
|
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
|
@@ -68142,37 +68145,33 @@ var ts;
|
|
|
68142
68145
|
var commonBaseType;
|
|
68143
68146
|
for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
|
|
68144
68147
|
var t = types_13[_i];
|
|
68145
|
-
|
|
68146
|
-
|
|
68147
|
-
commonBaseType = baseType;
|
|
68148
|
-
|
|
68149
|
-
|
|
68150
|
-
|
|
68148
|
+
if (!(t.flags & 131072 /* Never */)) {
|
|
68149
|
+
var baseType = getBaseTypeOfLiteralType(t);
|
|
68150
|
+
commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
|
|
68151
|
+
if (baseType === t || baseType !== commonBaseType) {
|
|
68152
|
+
return false;
|
|
68153
|
+
}
|
|
68151
68154
|
}
|
|
68152
68155
|
}
|
|
68153
68156
|
return true;
|
|
68154
68157
|
}
|
|
68155
|
-
|
|
68156
|
-
|
|
68157
|
-
// right is a supertype.
|
|
68158
|
-
function getSupertypeOrUnion(types) {
|
|
68159
|
-
if (types.length === 1) {
|
|
68160
|
-
return types[0];
|
|
68161
|
-
}
|
|
68162
|
-
return literalTypesWithSameBaseType(types) ?
|
|
68163
|
-
getUnionType(types) :
|
|
68164
|
-
ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68158
|
+
function getCombinedTypeFlags(types) {
|
|
68159
|
+
return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
|
|
68165
68160
|
}
|
|
68166
68161
|
function getCommonSupertype(types) {
|
|
68167
|
-
if (
|
|
68168
|
-
return
|
|
68169
|
-
}
|
|
68170
|
-
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
68171
|
-
if (primaryTypes.length) {
|
|
68172
|
-
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
68173
|
-
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
68162
|
+
if (types.length === 1) {
|
|
68163
|
+
return types[0];
|
|
68174
68164
|
}
|
|
68175
|
-
|
|
68165
|
+
// Remove nullable types from each of the candidates.
|
|
68166
|
+
var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* Nullable */); }); }) : types;
|
|
68167
|
+
// When the candidate types are all literal types with the same base type, return a union
|
|
68168
|
+
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
|
68169
|
+
// right is a supertype.
|
|
68170
|
+
var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
|
|
68171
|
+
getUnionType(primaryTypes) :
|
|
68172
|
+
ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68173
|
+
// Add any nullable types that occurred in the candidates back to the result.
|
|
68174
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
68176
68175
|
}
|
|
68177
68176
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
68178
68177
|
function getCommonSubtype(types) {
|
|
@@ -72146,8 +72145,12 @@ var ts;
|
|
|
72146
72145
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
72147
72146
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
72148
72147
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
72149
|
-
// specific of the two.
|
|
72150
|
-
|
|
72148
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
72149
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
72150
|
+
// prototype object types.
|
|
72151
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
72152
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
72153
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
72151
72154
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
72152
72155
|
// are related by constraint.
|
|
72153
72156
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -90766,7 +90769,7 @@ var ts;
|
|
|
90766
90769
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90767
90770
|
case 197 /* NamedTupleMember */:
|
|
90768
90771
|
ts.Debug.type(node);
|
|
90769
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90772
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90770
90773
|
case 191 /* ParenthesizedType */:
|
|
90771
90774
|
ts.Debug.type(node);
|
|
90772
90775
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -156006,8 +156009,7 @@ var ts;
|
|
|
156006
156009
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
156007
156010
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
156008
156011
|
if (info) {
|
|
156009
|
-
|
|
156010
|
-
if (ts.addToSeen(seen, id)) {
|
|
156012
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
156011
156013
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156012
156014
|
}
|
|
156013
156015
|
}
|
|
@@ -159975,21 +159977,16 @@ var ts;
|
|
|
159975
159977
|
var names = ts.map(args, function (arg) {
|
|
159976
159978
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159977
159979
|
});
|
|
159978
|
-
var
|
|
159979
|
-
|
|
159980
|
-
});
|
|
159980
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159981
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159981
159982
|
var modifiers = modifierFlags
|
|
159982
159983
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159983
159984
|
: undefined;
|
|
159984
159985
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159985
159986
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159986
159987
|
: undefined;
|
|
159987
|
-
var typeParameters = isJs
|
|
159988
|
-
|
|
159989
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159990
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159991
|
-
});
|
|
159992
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159988
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159989
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159993
159990
|
var type = isJs || contextualType === undefined
|
|
159994
159991
|
? undefined
|
|
159995
159992
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -160007,6 +160004,23 @@ var ts;
|
|
|
160007
160004
|
}
|
|
160008
160005
|
}
|
|
160009
160006
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
160007
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
160008
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
160009
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
160010
|
+
if (typeArguments) {
|
|
160011
|
+
var typeArgumentsWithNewTypes = typeArguments.filter(function (typeArgument) { return !argumentTypeParameters.some(function (pair) { var _a; return checker.getTypeAtLocation(typeArgument) === ((_a = pair[1]) === null || _a === void 0 ? void 0 : _a.argumentType); }); });
|
|
160012
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
160013
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
160014
|
+
usedNames.add(createTypeParameterName(i));
|
|
160015
|
+
}
|
|
160016
|
+
}
|
|
160017
|
+
return ts.map(ts.arrayFrom(usedNames.values()), function (usedName) { var _a; return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, (_a = constraintsByName.get(usedName)) === null || _a === void 0 ? void 0 : _a.constraint); });
|
|
160018
|
+
}
|
|
160019
|
+
function createTypeParameterName(index) {
|
|
160020
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
160021
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
160022
|
+
: "T" + index;
|
|
160023
|
+
}
|
|
160010
160024
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
160011
160025
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
160012
160026
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -160020,15 +160034,107 @@ var ts;
|
|
|
160020
160034
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
160021
160035
|
}
|
|
160022
160036
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
160037
|
+
function typeContainsTypeParameter(type) {
|
|
160038
|
+
if (type.isUnionOrIntersection()) {
|
|
160039
|
+
return type.types.some(typeContainsTypeParameter);
|
|
160040
|
+
}
|
|
160041
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
160042
|
+
}
|
|
160043
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
160044
|
+
// Types to be used as the types of the parameters in the new function
|
|
160045
|
+
// E.g. from this source:
|
|
160046
|
+
// added("", 0)
|
|
160047
|
+
// The value will look like:
|
|
160048
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
160049
|
+
// And in the output function will generate:
|
|
160050
|
+
// function added(a: string, b: number) { ... }
|
|
160051
|
+
var argumentTypeNodes = [];
|
|
160052
|
+
// Names of type parameters provided as arguments to the call
|
|
160053
|
+
// E.g. from this source:
|
|
160054
|
+
// added<T, U>(value);
|
|
160055
|
+
// The value will look like:
|
|
160056
|
+
// [
|
|
160057
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
160058
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
160059
|
+
// ]
|
|
160060
|
+
// And in the output function will generate:
|
|
160061
|
+
// function added<T, U>() { ... }
|
|
160062
|
+
var argumentTypeParameters = new ts.Map();
|
|
160063
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
160064
|
+
var instanceType = instanceTypes[i];
|
|
160065
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
160066
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
160067
|
+
// E.g. from this source:
|
|
160068
|
+
// function existing<T, U>(value: T | U & string) {
|
|
160069
|
+
// added/*1*/(value);
|
|
160070
|
+
// We don't want to output this:
|
|
160071
|
+
// function added<T>(value: T | U & string) { ... }
|
|
160072
|
+
// We instead want to output:
|
|
160073
|
+
// function added<T>(value: T) { ... }
|
|
160074
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
160075
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
160076
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
160077
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
160078
|
+
continue;
|
|
160079
|
+
}
|
|
160080
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
160081
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
160082
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
160083
|
+
if (!argumentTypeNode) {
|
|
160084
|
+
continue;
|
|
160085
|
+
}
|
|
160086
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
160087
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
160088
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
160089
|
+
// remember that constraint for when we create the new type parameter
|
|
160090
|
+
// E.g. from this source:
|
|
160091
|
+
// function existing<T extends string>(value: T) {
|
|
160092
|
+
// added/*1*/(value);
|
|
160093
|
+
// We don't want to output this:
|
|
160094
|
+
// function added<T>(value: T) { ... }
|
|
160095
|
+
// We instead want to output:
|
|
160096
|
+
// function added<T extends string>(value: T) { ... }
|
|
160097
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
160098
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
160099
|
+
: undefined;
|
|
160100
|
+
if (argumentTypeParameter) {
|
|
160101
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
160102
|
+
}
|
|
160103
|
+
}
|
|
160104
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
160105
|
+
}
|
|
160106
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
160107
|
+
function isAnonymousObjectConstraintType(type) {
|
|
160108
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
160109
|
+
}
|
|
160110
|
+
function getFirstTypeParameterName(type) {
|
|
160111
|
+
var _a;
|
|
160112
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
160113
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
160114
|
+
var subType = _b[_i];
|
|
160115
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
160116
|
+
if (subTypeName) {
|
|
160117
|
+
return subTypeName;
|
|
160118
|
+
}
|
|
160119
|
+
}
|
|
160120
|
+
}
|
|
160121
|
+
return type.flags & 262144 /* TypeParameter */
|
|
160122
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
160123
|
+
: undefined;
|
|
160124
|
+
}
|
|
160023
160125
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
160024
160126
|
var parameters = [];
|
|
160127
|
+
var parameterNameCounts = new ts.Map();
|
|
160025
160128
|
for (var i = 0; i < argCount; i++) {
|
|
160129
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
160130
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
160131
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
160026
160132
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
160027
160133
|
/*modifiers*/ undefined,
|
|
160028
160134
|
/*dotDotDotToken*/ undefined,
|
|
160029
|
-
/*name*/
|
|
160135
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
160030
160136
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
160031
|
-
/*type*/ inJs ? undefined : types
|
|
160137
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
160032
160138
|
/*initializer*/ undefined);
|
|
160033
160139
|
parameters.push(newParameter);
|
|
160034
160140
|
}
|