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/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.20220727";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8762,6 +8762,7 @@ var ts;
|
|
|
8762
8762
|
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."),
|
|
8763
8763
|
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."),
|
|
8764
8764
|
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."),
|
|
8765
|
+
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8765
8766
|
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."),
|
|
8766
8767
|
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."),
|
|
8767
8768
|
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),
|
|
@@ -33501,7 +33502,9 @@ var ts;
|
|
|
33501
33502
|
case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33502
33503
|
case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33503
33504
|
case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33504
|
-
|
|
33505
|
+
case 24 /* AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
|
|
33506
|
+
case 25 /* Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
|
|
33507
|
+
default: ts.Debug.assertNever(context);
|
|
33505
33508
|
}
|
|
33506
33509
|
}
|
|
33507
33510
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
@@ -33942,7 +33945,7 @@ var ts;
|
|
|
33942
33945
|
// FormalParameter [Yield,Await]:
|
|
33943
33946
|
// BindingElement[?Yield,?Await]
|
|
33944
33947
|
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
|
33945
|
-
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators
|
|
33948
|
+
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
|
|
33946
33949
|
if (token() === 108 /* ThisKeyword */) {
|
|
33947
33950
|
var node_1 = factory.createParameterDeclaration(decorators,
|
|
33948
33951
|
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
|
@@ -68133,37 +68136,33 @@ var ts;
|
|
|
68133
68136
|
var commonBaseType;
|
|
68134
68137
|
for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
|
|
68135
68138
|
var t = types_13[_i];
|
|
68136
|
-
|
|
68137
|
-
|
|
68138
|
-
commonBaseType = baseType;
|
|
68139
|
-
|
|
68140
|
-
|
|
68141
|
-
|
|
68139
|
+
if (!(t.flags & 131072 /* Never */)) {
|
|
68140
|
+
var baseType = getBaseTypeOfLiteralType(t);
|
|
68141
|
+
commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
|
|
68142
|
+
if (baseType === t || baseType !== commonBaseType) {
|
|
68143
|
+
return false;
|
|
68144
|
+
}
|
|
68142
68145
|
}
|
|
68143
68146
|
}
|
|
68144
68147
|
return true;
|
|
68145
68148
|
}
|
|
68146
|
-
|
|
68147
|
-
|
|
68148
|
-
// right is a supertype.
|
|
68149
|
-
function getSupertypeOrUnion(types) {
|
|
68150
|
-
if (types.length === 1) {
|
|
68151
|
-
return types[0];
|
|
68152
|
-
}
|
|
68153
|
-
return literalTypesWithSameBaseType(types) ?
|
|
68154
|
-
getUnionType(types) :
|
|
68155
|
-
ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68149
|
+
function getCombinedTypeFlags(types) {
|
|
68150
|
+
return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
|
|
68156
68151
|
}
|
|
68157
68152
|
function getCommonSupertype(types) {
|
|
68158
|
-
if (
|
|
68159
|
-
return
|
|
68160
|
-
}
|
|
68161
|
-
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
68162
|
-
if (primaryTypes.length) {
|
|
68163
|
-
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
68164
|
-
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
68153
|
+
if (types.length === 1) {
|
|
68154
|
+
return types[0];
|
|
68165
68155
|
}
|
|
68166
|
-
|
|
68156
|
+
// Remove nullable types from each of the candidates.
|
|
68157
|
+
var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* Nullable */); }); }) : types;
|
|
68158
|
+
// When the candidate types are all literal types with the same base type, return a union
|
|
68159
|
+
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
|
68160
|
+
// right is a supertype.
|
|
68161
|
+
var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
|
|
68162
|
+
getUnionType(primaryTypes) :
|
|
68163
|
+
ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68164
|
+
// Add any nullable types that occurred in the candidates back to the result.
|
|
68165
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
68167
68166
|
}
|
|
68168
68167
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
68169
68168
|
function getCommonSubtype(types) {
|
|
@@ -72137,8 +72136,12 @@ var ts;
|
|
|
72137
72136
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
72138
72137
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
72139
72138
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
72140
|
-
// specific of the two.
|
|
72141
|
-
|
|
72139
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
72140
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
72141
|
+
// prototype object types.
|
|
72142
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
72143
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
72144
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
72142
72145
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
72143
72146
|
// are related by constraint.
|
|
72144
72147
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -90757,7 +90760,7 @@ var ts;
|
|
|
90757
90760
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90758
90761
|
case 197 /* NamedTupleMember */:
|
|
90759
90762
|
ts.Debug.type(node);
|
|
90760
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90763
|
+
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));
|
|
90761
90764
|
case 191 /* ParenthesizedType */:
|
|
90762
90765
|
ts.Debug.type(node);
|
|
90763
90766
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -155997,8 +156000,7 @@ var ts;
|
|
|
155997
156000
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155998
156001
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155999
156002
|
if (info) {
|
|
156000
|
-
|
|
156001
|
-
if (ts.addToSeen(seen, id)) {
|
|
156003
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
156002
156004
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156003
156005
|
}
|
|
156004
156006
|
}
|
|
@@ -159966,21 +159968,16 @@ var ts;
|
|
|
159966
159968
|
var names = ts.map(args, function (arg) {
|
|
159967
159969
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159968
159970
|
});
|
|
159969
|
-
var
|
|
159970
|
-
|
|
159971
|
-
});
|
|
159971
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159972
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159972
159973
|
var modifiers = modifierFlags
|
|
159973
159974
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159974
159975
|
: undefined;
|
|
159975
159976
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159976
159977
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159977
159978
|
: undefined;
|
|
159978
|
-
var typeParameters = isJs
|
|
159979
|
-
|
|
159980
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159981
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159982
|
-
});
|
|
159983
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159979
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159980
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159984
159981
|
var type = isJs || contextualType === undefined
|
|
159985
159982
|
? undefined
|
|
159986
159983
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -159998,6 +159995,23 @@ var ts;
|
|
|
159998
159995
|
}
|
|
159999
159996
|
}
|
|
160000
159997
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
159998
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
159999
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
160000
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
160001
|
+
if (typeArguments) {
|
|
160002
|
+
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); }); });
|
|
160003
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
160004
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
160005
|
+
usedNames.add(createTypeParameterName(i));
|
|
160006
|
+
}
|
|
160007
|
+
}
|
|
160008
|
+
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); });
|
|
160009
|
+
}
|
|
160010
|
+
function createTypeParameterName(index) {
|
|
160011
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
160012
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
160013
|
+
: "T" + index;
|
|
160014
|
+
}
|
|
160001
160015
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
160002
160016
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
160003
160017
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -160011,15 +160025,107 @@ var ts;
|
|
|
160011
160025
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
160012
160026
|
}
|
|
160013
160027
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
160028
|
+
function typeContainsTypeParameter(type) {
|
|
160029
|
+
if (type.isUnionOrIntersection()) {
|
|
160030
|
+
return type.types.some(typeContainsTypeParameter);
|
|
160031
|
+
}
|
|
160032
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
160033
|
+
}
|
|
160034
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
160035
|
+
// Types to be used as the types of the parameters in the new function
|
|
160036
|
+
// E.g. from this source:
|
|
160037
|
+
// added("", 0)
|
|
160038
|
+
// The value will look like:
|
|
160039
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
160040
|
+
// And in the output function will generate:
|
|
160041
|
+
// function added(a: string, b: number) { ... }
|
|
160042
|
+
var argumentTypeNodes = [];
|
|
160043
|
+
// Names of type parameters provided as arguments to the call
|
|
160044
|
+
// E.g. from this source:
|
|
160045
|
+
// added<T, U>(value);
|
|
160046
|
+
// The value will look like:
|
|
160047
|
+
// [
|
|
160048
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
160049
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
160050
|
+
// ]
|
|
160051
|
+
// And in the output function will generate:
|
|
160052
|
+
// function added<T, U>() { ... }
|
|
160053
|
+
var argumentTypeParameters = new ts.Map();
|
|
160054
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
160055
|
+
var instanceType = instanceTypes[i];
|
|
160056
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
160057
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
160058
|
+
// E.g. from this source:
|
|
160059
|
+
// function existing<T, U>(value: T | U & string) {
|
|
160060
|
+
// added/*1*/(value);
|
|
160061
|
+
// We don't want to output this:
|
|
160062
|
+
// function added<T>(value: T | U & string) { ... }
|
|
160063
|
+
// We instead want to output:
|
|
160064
|
+
// function added<T>(value: T) { ... }
|
|
160065
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
160066
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
160067
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
160068
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
160069
|
+
continue;
|
|
160070
|
+
}
|
|
160071
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
160072
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
160073
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
160074
|
+
if (!argumentTypeNode) {
|
|
160075
|
+
continue;
|
|
160076
|
+
}
|
|
160077
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
160078
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
160079
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
160080
|
+
// remember that constraint for when we create the new type parameter
|
|
160081
|
+
// E.g. from this source:
|
|
160082
|
+
// function existing<T extends string>(value: T) {
|
|
160083
|
+
// added/*1*/(value);
|
|
160084
|
+
// We don't want to output this:
|
|
160085
|
+
// function added<T>(value: T) { ... }
|
|
160086
|
+
// We instead want to output:
|
|
160087
|
+
// function added<T extends string>(value: T) { ... }
|
|
160088
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
160089
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
160090
|
+
: undefined;
|
|
160091
|
+
if (argumentTypeParameter) {
|
|
160092
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
160093
|
+
}
|
|
160094
|
+
}
|
|
160095
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
160096
|
+
}
|
|
160097
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
160098
|
+
function isAnonymousObjectConstraintType(type) {
|
|
160099
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
160100
|
+
}
|
|
160101
|
+
function getFirstTypeParameterName(type) {
|
|
160102
|
+
var _a;
|
|
160103
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
160104
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
160105
|
+
var subType = _b[_i];
|
|
160106
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
160107
|
+
if (subTypeName) {
|
|
160108
|
+
return subTypeName;
|
|
160109
|
+
}
|
|
160110
|
+
}
|
|
160111
|
+
}
|
|
160112
|
+
return type.flags & 262144 /* TypeParameter */
|
|
160113
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
160114
|
+
: undefined;
|
|
160115
|
+
}
|
|
160014
160116
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
160015
160117
|
var parameters = [];
|
|
160118
|
+
var parameterNameCounts = new ts.Map();
|
|
160016
160119
|
for (var i = 0; i < argCount; i++) {
|
|
160120
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
160121
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
160122
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
160017
160123
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
160018
160124
|
/*modifiers*/ undefined,
|
|
160019
160125
|
/*dotDotDotToken*/ undefined,
|
|
160020
|
-
/*name*/
|
|
160126
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
160021
160127
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
160022
|
-
/*type*/ inJs ? undefined : types
|
|
160128
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
160023
160129
|
/*initializer*/ undefined);
|
|
160024
160130
|
parameters.push(newParameter);
|
|
160025
160131
|
}
|
|
@@ -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.20220727";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8762,6 +8762,7 @@ var ts;
|
|
|
8762
8762
|
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."),
|
|
8763
8763
|
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."),
|
|
8764
8764
|
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."),
|
|
8765
|
+
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8765
8766
|
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."),
|
|
8766
8767
|
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."),
|
|
8767
8768
|
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),
|
|
@@ -33501,7 +33502,9 @@ var ts;
|
|
|
33501
33502
|
case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33502
33503
|
case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33503
33504
|
case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
33504
|
-
|
|
33505
|
+
case 24 /* AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
|
|
33506
|
+
case 25 /* Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
|
|
33507
|
+
default: ts.Debug.assertNever(context);
|
|
33505
33508
|
}
|
|
33506
33509
|
}
|
|
33507
33510
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
@@ -33942,7 +33945,7 @@ var ts;
|
|
|
33942
33945
|
// FormalParameter [Yield,Await]:
|
|
33943
33946
|
// BindingElement[?Yield,?Await]
|
|
33944
33947
|
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
|
33945
|
-
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators
|
|
33948
|
+
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
|
|
33946
33949
|
if (token() === 108 /* ThisKeyword */) {
|
|
33947
33950
|
var node_1 = factory.createParameterDeclaration(decorators,
|
|
33948
33951
|
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
|
@@ -68133,37 +68136,33 @@ var ts;
|
|
|
68133
68136
|
var commonBaseType;
|
|
68134
68137
|
for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
|
|
68135
68138
|
var t = types_13[_i];
|
|
68136
|
-
|
|
68137
|
-
|
|
68138
|
-
commonBaseType = baseType;
|
|
68139
|
-
|
|
68140
|
-
|
|
68141
|
-
|
|
68139
|
+
if (!(t.flags & 131072 /* Never */)) {
|
|
68140
|
+
var baseType = getBaseTypeOfLiteralType(t);
|
|
68141
|
+
commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
|
|
68142
|
+
if (baseType === t || baseType !== commonBaseType) {
|
|
68143
|
+
return false;
|
|
68144
|
+
}
|
|
68142
68145
|
}
|
|
68143
68146
|
}
|
|
68144
68147
|
return true;
|
|
68145
68148
|
}
|
|
68146
|
-
|
|
68147
|
-
|
|
68148
|
-
// right is a supertype.
|
|
68149
|
-
function getSupertypeOrUnion(types) {
|
|
68150
|
-
if (types.length === 1) {
|
|
68151
|
-
return types[0];
|
|
68152
|
-
}
|
|
68153
|
-
return literalTypesWithSameBaseType(types) ?
|
|
68154
|
-
getUnionType(types) :
|
|
68155
|
-
ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68149
|
+
function getCombinedTypeFlags(types) {
|
|
68150
|
+
return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
|
|
68156
68151
|
}
|
|
68157
68152
|
function getCommonSupertype(types) {
|
|
68158
|
-
if (
|
|
68159
|
-
return
|
|
68160
|
-
}
|
|
68161
|
-
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
68162
|
-
if (primaryTypes.length) {
|
|
68163
|
-
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
68164
|
-
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
68153
|
+
if (types.length === 1) {
|
|
68154
|
+
return types[0];
|
|
68165
68155
|
}
|
|
68166
|
-
|
|
68156
|
+
// Remove nullable types from each of the candidates.
|
|
68157
|
+
var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* Nullable */); }); }) : types;
|
|
68158
|
+
// When the candidate types are all literal types with the same base type, return a union
|
|
68159
|
+
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
|
68160
|
+
// right is a supertype.
|
|
68161
|
+
var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
|
|
68162
|
+
getUnionType(primaryTypes) :
|
|
68163
|
+
ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68164
|
+
// Add any nullable types that occurred in the candidates back to the result.
|
|
68165
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
68167
68166
|
}
|
|
68168
68167
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
68169
68168
|
function getCommonSubtype(types) {
|
|
@@ -72137,8 +72136,12 @@ var ts;
|
|
|
72137
72136
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
72138
72137
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
72139
72138
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
72140
|
-
// specific of the two.
|
|
72141
|
-
|
|
72139
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
72140
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
72141
|
+
// prototype object types.
|
|
72142
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
72143
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
72144
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
72142
72145
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
72143
72146
|
// are related by constraint.
|
|
72144
72147
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -90757,7 +90760,7 @@ var ts;
|
|
|
90757
90760
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90758
90761
|
case 197 /* NamedTupleMember */:
|
|
90759
90762
|
ts.Debug.type(node);
|
|
90760
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90763
|
+
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));
|
|
90761
90764
|
case 191 /* ParenthesizedType */:
|
|
90762
90765
|
ts.Debug.type(node);
|
|
90763
90766
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -155997,8 +156000,7 @@ var ts;
|
|
|
155997
156000
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155998
156001
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155999
156002
|
if (info) {
|
|
156000
|
-
|
|
156001
|
-
if (ts.addToSeen(seen, id)) {
|
|
156003
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
156002
156004
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156003
156005
|
}
|
|
156004
156006
|
}
|
|
@@ -159966,21 +159968,16 @@ var ts;
|
|
|
159966
159968
|
var names = ts.map(args, function (arg) {
|
|
159967
159969
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159968
159970
|
});
|
|
159969
|
-
var
|
|
159970
|
-
|
|
159971
|
-
});
|
|
159971
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159972
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159972
159973
|
var modifiers = modifierFlags
|
|
159973
159974
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159974
159975
|
: undefined;
|
|
159975
159976
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159976
159977
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159977
159978
|
: undefined;
|
|
159978
|
-
var typeParameters = isJs
|
|
159979
|
-
|
|
159980
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159981
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159982
|
-
});
|
|
159983
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159979
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159980
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159984
159981
|
var type = isJs || contextualType === undefined
|
|
159985
159982
|
? undefined
|
|
159986
159983
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -159998,6 +159995,23 @@ var ts;
|
|
|
159998
159995
|
}
|
|
159999
159996
|
}
|
|
160000
159997
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
159998
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
159999
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
160000
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
160001
|
+
if (typeArguments) {
|
|
160002
|
+
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); }); });
|
|
160003
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
160004
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
160005
|
+
usedNames.add(createTypeParameterName(i));
|
|
160006
|
+
}
|
|
160007
|
+
}
|
|
160008
|
+
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); });
|
|
160009
|
+
}
|
|
160010
|
+
function createTypeParameterName(index) {
|
|
160011
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
160012
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
160013
|
+
: "T" + index;
|
|
160014
|
+
}
|
|
160001
160015
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
160002
160016
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
160003
160017
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -160011,15 +160025,107 @@ var ts;
|
|
|
160011
160025
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
160012
160026
|
}
|
|
160013
160027
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
160028
|
+
function typeContainsTypeParameter(type) {
|
|
160029
|
+
if (type.isUnionOrIntersection()) {
|
|
160030
|
+
return type.types.some(typeContainsTypeParameter);
|
|
160031
|
+
}
|
|
160032
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
160033
|
+
}
|
|
160034
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
160035
|
+
// Types to be used as the types of the parameters in the new function
|
|
160036
|
+
// E.g. from this source:
|
|
160037
|
+
// added("", 0)
|
|
160038
|
+
// The value will look like:
|
|
160039
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
160040
|
+
// And in the output function will generate:
|
|
160041
|
+
// function added(a: string, b: number) { ... }
|
|
160042
|
+
var argumentTypeNodes = [];
|
|
160043
|
+
// Names of type parameters provided as arguments to the call
|
|
160044
|
+
// E.g. from this source:
|
|
160045
|
+
// added<T, U>(value);
|
|
160046
|
+
// The value will look like:
|
|
160047
|
+
// [
|
|
160048
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
160049
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
160050
|
+
// ]
|
|
160051
|
+
// And in the output function will generate:
|
|
160052
|
+
// function added<T, U>() { ... }
|
|
160053
|
+
var argumentTypeParameters = new ts.Map();
|
|
160054
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
160055
|
+
var instanceType = instanceTypes[i];
|
|
160056
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
160057
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
160058
|
+
// E.g. from this source:
|
|
160059
|
+
// function existing<T, U>(value: T | U & string) {
|
|
160060
|
+
// added/*1*/(value);
|
|
160061
|
+
// We don't want to output this:
|
|
160062
|
+
// function added<T>(value: T | U & string) { ... }
|
|
160063
|
+
// We instead want to output:
|
|
160064
|
+
// function added<T>(value: T) { ... }
|
|
160065
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
160066
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
160067
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
160068
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
160069
|
+
continue;
|
|
160070
|
+
}
|
|
160071
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
160072
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
160073
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
160074
|
+
if (!argumentTypeNode) {
|
|
160075
|
+
continue;
|
|
160076
|
+
}
|
|
160077
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
160078
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
160079
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
160080
|
+
// remember that constraint for when we create the new type parameter
|
|
160081
|
+
// E.g. from this source:
|
|
160082
|
+
// function existing<T extends string>(value: T) {
|
|
160083
|
+
// added/*1*/(value);
|
|
160084
|
+
// We don't want to output this:
|
|
160085
|
+
// function added<T>(value: T) { ... }
|
|
160086
|
+
// We instead want to output:
|
|
160087
|
+
// function added<T extends string>(value: T) { ... }
|
|
160088
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
160089
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
160090
|
+
: undefined;
|
|
160091
|
+
if (argumentTypeParameter) {
|
|
160092
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
160093
|
+
}
|
|
160094
|
+
}
|
|
160095
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
160096
|
+
}
|
|
160097
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
160098
|
+
function isAnonymousObjectConstraintType(type) {
|
|
160099
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
160100
|
+
}
|
|
160101
|
+
function getFirstTypeParameterName(type) {
|
|
160102
|
+
var _a;
|
|
160103
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
160104
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
160105
|
+
var subType = _b[_i];
|
|
160106
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
160107
|
+
if (subTypeName) {
|
|
160108
|
+
return subTypeName;
|
|
160109
|
+
}
|
|
160110
|
+
}
|
|
160111
|
+
}
|
|
160112
|
+
return type.flags & 262144 /* TypeParameter */
|
|
160113
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
160114
|
+
: undefined;
|
|
160115
|
+
}
|
|
160014
160116
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
160015
160117
|
var parameters = [];
|
|
160118
|
+
var parameterNameCounts = new ts.Map();
|
|
160016
160119
|
for (var i = 0; i < argCount; i++) {
|
|
160120
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
160121
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
160122
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
160017
160123
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
160018
160124
|
/*modifiers*/ undefined,
|
|
160019
160125
|
/*dotDotDotToken*/ undefined,
|
|
160020
|
-
/*name*/
|
|
160126
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
160021
160127
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
160022
|
-
/*type*/ inJs ? undefined : types
|
|
160128
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
160023
160129
|
/*initializer*/ undefined);
|
|
160024
160130
|
parameters.push(newParameter);
|
|
160025
160131
|
}
|