typescript 4.8.0-dev.20220725 → 4.8.0-dev.20220728
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/lib.es2015.proxy.d.ts +91 -2
- package/lib/tsc.js +19 -9
- package/lib/tsserver.js +143 -27
- package/lib/tsserverlibrary.js +143 -27
- package/lib/typescript.js +143 -27
- package/lib/typescriptServices.js +143 -27
- package/lib/typingsInstaller.js +24 -11
- package/package.json +4 -3
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.20220728";
|
|
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),
|
|
@@ -59616,7 +59619,8 @@ var ts;
|
|
|
59616
59619
|
}
|
|
59617
59620
|
}
|
|
59618
59621
|
}
|
|
59619
|
-
|
|
59622
|
+
// The source types were normalized; ensure the result is normalized too.
|
|
59623
|
+
return getNormalizedType(getIntersectionType(constraints), /*writing*/ false);
|
|
59620
59624
|
}
|
|
59621
59625
|
return undefined;
|
|
59622
59626
|
}
|
|
@@ -72142,8 +72146,12 @@ var ts;
|
|
|
72142
72146
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
72143
72147
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
72144
72148
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
72145
|
-
// specific of the two.
|
|
72146
|
-
|
|
72149
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
72150
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
72151
|
+
// prototype object types.
|
|
72152
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
72153
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
72154
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
72147
72155
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
72148
72156
|
// are related by constraint.
|
|
72149
72157
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -84855,8 +84863,9 @@ var ts;
|
|
|
84855
84863
|
}
|
|
84856
84864
|
var indexInfos = getApplicableIndexInfos(type, propNameType);
|
|
84857
84865
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
84858
|
-
var
|
|
84859
|
-
name && name.kind === 162 /* ComputedPropertyName */
|
|
84866
|
+
var propDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
|
|
84867
|
+
name && name.kind === 162 /* ComputedPropertyName */ ? declaration : undefined;
|
|
84868
|
+
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
84860
84869
|
var _loop_30 = function (info) {
|
|
84861
84870
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
84862
84871
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
@@ -84865,7 +84874,11 @@ var ts;
|
|
|
84865
84874
|
var errorNode = localPropDeclaration || localIndexDeclaration ||
|
|
84866
84875
|
(interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
|
|
84867
84876
|
if (errorNode && !isTypeAssignableTo(propType, info.type)) {
|
|
84868
|
-
|
|
84877
|
+
var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
|
|
84878
|
+
if (propDeclaration && errorNode !== propDeclaration) {
|
|
84879
|
+
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
|
|
84880
|
+
}
|
|
84881
|
+
diagnostics.add(diagnostic);
|
|
84869
84882
|
}
|
|
84870
84883
|
};
|
|
84871
84884
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
@@ -90762,7 +90775,7 @@ var ts;
|
|
|
90762
90775
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90763
90776
|
case 197 /* NamedTupleMember */:
|
|
90764
90777
|
ts.Debug.type(node);
|
|
90765
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90778
|
+
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));
|
|
90766
90779
|
case 191 /* ParenthesizedType */:
|
|
90767
90780
|
ts.Debug.type(node);
|
|
90768
90781
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -118516,7 +118529,7 @@ var ts;
|
|
|
118516
118529
|
// `result[i]` is either a `ResolvedModuleFull` or a marker.
|
|
118517
118530
|
// If it is the former, we can leave it as is.
|
|
118518
118531
|
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
|
118519
|
-
result[i] = undefined;
|
|
118532
|
+
result[i] = undefined;
|
|
118520
118533
|
}
|
|
118521
118534
|
}
|
|
118522
118535
|
else {
|
|
@@ -156002,8 +156015,7 @@ var ts;
|
|
|
156002
156015
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
156003
156016
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
156004
156017
|
if (info) {
|
|
156005
|
-
|
|
156006
|
-
if (ts.addToSeen(seen, id)) {
|
|
156018
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
156007
156019
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156008
156020
|
}
|
|
156009
156021
|
}
|
|
@@ -159971,21 +159983,16 @@ var ts;
|
|
|
159971
159983
|
var names = ts.map(args, function (arg) {
|
|
159972
159984
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159973
159985
|
});
|
|
159974
|
-
var
|
|
159975
|
-
|
|
159976
|
-
});
|
|
159986
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159987
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159977
159988
|
var modifiers = modifierFlags
|
|
159978
159989
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159979
159990
|
: undefined;
|
|
159980
159991
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159981
159992
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159982
159993
|
: undefined;
|
|
159983
|
-
var typeParameters = isJs
|
|
159984
|
-
|
|
159985
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159986
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159987
|
-
});
|
|
159988
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159994
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159995
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159989
159996
|
var type = isJs || contextualType === undefined
|
|
159990
159997
|
? undefined
|
|
159991
159998
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -160003,6 +160010,23 @@ var ts;
|
|
|
160003
160010
|
}
|
|
160004
160011
|
}
|
|
160005
160012
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
160013
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
160014
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
160015
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
160016
|
+
if (typeArguments) {
|
|
160017
|
+
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); }); });
|
|
160018
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
160019
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
160020
|
+
usedNames.add(createTypeParameterName(i));
|
|
160021
|
+
}
|
|
160022
|
+
}
|
|
160023
|
+
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); });
|
|
160024
|
+
}
|
|
160025
|
+
function createTypeParameterName(index) {
|
|
160026
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
160027
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
160028
|
+
: "T" + index;
|
|
160029
|
+
}
|
|
160006
160030
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
160007
160031
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
160008
160032
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -160016,15 +160040,107 @@ var ts;
|
|
|
160016
160040
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
160017
160041
|
}
|
|
160018
160042
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
160043
|
+
function typeContainsTypeParameter(type) {
|
|
160044
|
+
if (type.isUnionOrIntersection()) {
|
|
160045
|
+
return type.types.some(typeContainsTypeParameter);
|
|
160046
|
+
}
|
|
160047
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
160048
|
+
}
|
|
160049
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
160050
|
+
// Types to be used as the types of the parameters in the new function
|
|
160051
|
+
// E.g. from this source:
|
|
160052
|
+
// added("", 0)
|
|
160053
|
+
// The value will look like:
|
|
160054
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
160055
|
+
// And in the output function will generate:
|
|
160056
|
+
// function added(a: string, b: number) { ... }
|
|
160057
|
+
var argumentTypeNodes = [];
|
|
160058
|
+
// Names of type parameters provided as arguments to the call
|
|
160059
|
+
// E.g. from this source:
|
|
160060
|
+
// added<T, U>(value);
|
|
160061
|
+
// The value will look like:
|
|
160062
|
+
// [
|
|
160063
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
160064
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
160065
|
+
// ]
|
|
160066
|
+
// And in the output function will generate:
|
|
160067
|
+
// function added<T, U>() { ... }
|
|
160068
|
+
var argumentTypeParameters = new ts.Map();
|
|
160069
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
160070
|
+
var instanceType = instanceTypes[i];
|
|
160071
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
160072
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
160073
|
+
// E.g. from this source:
|
|
160074
|
+
// function existing<T, U>(value: T | U & string) {
|
|
160075
|
+
// added/*1*/(value);
|
|
160076
|
+
// We don't want to output this:
|
|
160077
|
+
// function added<T>(value: T | U & string) { ... }
|
|
160078
|
+
// We instead want to output:
|
|
160079
|
+
// function added<T>(value: T) { ... }
|
|
160080
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
160081
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
160082
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
160083
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
160084
|
+
continue;
|
|
160085
|
+
}
|
|
160086
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
160087
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
160088
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
160089
|
+
if (!argumentTypeNode) {
|
|
160090
|
+
continue;
|
|
160091
|
+
}
|
|
160092
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
160093
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
160094
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
160095
|
+
// remember that constraint for when we create the new type parameter
|
|
160096
|
+
// E.g. from this source:
|
|
160097
|
+
// function existing<T extends string>(value: T) {
|
|
160098
|
+
// added/*1*/(value);
|
|
160099
|
+
// We don't want to output this:
|
|
160100
|
+
// function added<T>(value: T) { ... }
|
|
160101
|
+
// We instead want to output:
|
|
160102
|
+
// function added<T extends string>(value: T) { ... }
|
|
160103
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
160104
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
160105
|
+
: undefined;
|
|
160106
|
+
if (argumentTypeParameter) {
|
|
160107
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
160108
|
+
}
|
|
160109
|
+
}
|
|
160110
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
160111
|
+
}
|
|
160112
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
160113
|
+
function isAnonymousObjectConstraintType(type) {
|
|
160114
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
160115
|
+
}
|
|
160116
|
+
function getFirstTypeParameterName(type) {
|
|
160117
|
+
var _a;
|
|
160118
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
160119
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
160120
|
+
var subType = _b[_i];
|
|
160121
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
160122
|
+
if (subTypeName) {
|
|
160123
|
+
return subTypeName;
|
|
160124
|
+
}
|
|
160125
|
+
}
|
|
160126
|
+
}
|
|
160127
|
+
return type.flags & 262144 /* TypeParameter */
|
|
160128
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
160129
|
+
: undefined;
|
|
160130
|
+
}
|
|
160019
160131
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
160020
160132
|
var parameters = [];
|
|
160133
|
+
var parameterNameCounts = new ts.Map();
|
|
160021
160134
|
for (var i = 0; i < argCount; i++) {
|
|
160135
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
160136
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
160137
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
160022
160138
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
160023
160139
|
/*modifiers*/ undefined,
|
|
160024
160140
|
/*dotDotDotToken*/ undefined,
|
|
160025
|
-
/*name*/
|
|
160141
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
160026
160142
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
160027
|
-
/*type*/ inJs ? undefined : types
|
|
160143
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
160028
160144
|
/*initializer*/ undefined);
|
|
160029
160145
|
parameters.push(newParameter);
|
|
160030
160146
|
}
|
|
@@ -164156,7 +164272,7 @@ var ts;
|
|
|
164156
164272
|
var usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
164157
164273
|
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
|
|
164158
164274
|
var extension = ts.extensionFromPath(oldFile.fileName);
|
|
164159
|
-
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
|
|
164275
|
+
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host);
|
|
164160
164276
|
var newFileNameWithExtension = newModuleName + extension;
|
|
164161
164277
|
// If previous file was global, this is easy.
|
|
164162
164278
|
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences));
|
|
@@ -164520,8 +164636,8 @@ var ts;
|
|
|
164520
164636
|
newModuleName = moduleName + "." + i;
|
|
164521
164637
|
}
|
|
164522
164638
|
}
|
|
164523
|
-
function getNewModuleName(movedSymbols) {
|
|
164524
|
-
return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile";
|
|
164639
|
+
function getNewModuleName(importsFromNewFile, movedSymbols) {
|
|
164640
|
+
return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile";
|
|
164525
164641
|
}
|
|
164526
164642
|
function getUsageInfo(oldFile, toMove, checker) {
|
|
164527
164643
|
var movedSymbols = new SymbolSet();
|
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.20220728";
|
|
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),
|
|
@@ -59607,7 +59610,8 @@ var ts;
|
|
|
59607
59610
|
}
|
|
59608
59611
|
}
|
|
59609
59612
|
}
|
|
59610
|
-
|
|
59613
|
+
// The source types were normalized; ensure the result is normalized too.
|
|
59614
|
+
return getNormalizedType(getIntersectionType(constraints), /*writing*/ false);
|
|
59611
59615
|
}
|
|
59612
59616
|
return undefined;
|
|
59613
59617
|
}
|
|
@@ -72133,8 +72137,12 @@ var ts;
|
|
|
72133
72137
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
72134
72138
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
72135
72139
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
72136
|
-
// specific of the two.
|
|
72137
|
-
|
|
72140
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
72141
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
72142
|
+
// prototype object types.
|
|
72143
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
72144
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
72145
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
72138
72146
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
72139
72147
|
// are related by constraint.
|
|
72140
72148
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -84846,8 +84854,9 @@ var ts;
|
|
|
84846
84854
|
}
|
|
84847
84855
|
var indexInfos = getApplicableIndexInfos(type, propNameType);
|
|
84848
84856
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
84849
|
-
var
|
|
84850
|
-
name && name.kind === 162 /* ComputedPropertyName */
|
|
84857
|
+
var propDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
|
|
84858
|
+
name && name.kind === 162 /* ComputedPropertyName */ ? declaration : undefined;
|
|
84859
|
+
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
84851
84860
|
var _loop_30 = function (info) {
|
|
84852
84861
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
84853
84862
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
@@ -84856,7 +84865,11 @@ var ts;
|
|
|
84856
84865
|
var errorNode = localPropDeclaration || localIndexDeclaration ||
|
|
84857
84866
|
(interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
|
|
84858
84867
|
if (errorNode && !isTypeAssignableTo(propType, info.type)) {
|
|
84859
|
-
|
|
84868
|
+
var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
|
|
84869
|
+
if (propDeclaration && errorNode !== propDeclaration) {
|
|
84870
|
+
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
|
|
84871
|
+
}
|
|
84872
|
+
diagnostics.add(diagnostic);
|
|
84860
84873
|
}
|
|
84861
84874
|
};
|
|
84862
84875
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
@@ -90753,7 +90766,7 @@ var ts;
|
|
|
90753
90766
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90754
90767
|
case 197 /* NamedTupleMember */:
|
|
90755
90768
|
ts.Debug.type(node);
|
|
90756
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90769
|
+
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));
|
|
90757
90770
|
case 191 /* ParenthesizedType */:
|
|
90758
90771
|
ts.Debug.type(node);
|
|
90759
90772
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -118507,7 +118520,7 @@ var ts;
|
|
|
118507
118520
|
// `result[i]` is either a `ResolvedModuleFull` or a marker.
|
|
118508
118521
|
// If it is the former, we can leave it as is.
|
|
118509
118522
|
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
|
118510
|
-
result[i] = undefined;
|
|
118523
|
+
result[i] = undefined;
|
|
118511
118524
|
}
|
|
118512
118525
|
}
|
|
118513
118526
|
else {
|
|
@@ -155993,8 +156006,7 @@ var ts;
|
|
|
155993
156006
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155994
156007
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155995
156008
|
if (info) {
|
|
155996
|
-
|
|
155997
|
-
if (ts.addToSeen(seen, id)) {
|
|
156009
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
155998
156010
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
155999
156011
|
}
|
|
156000
156012
|
}
|
|
@@ -159962,21 +159974,16 @@ var ts;
|
|
|
159962
159974
|
var names = ts.map(args, function (arg) {
|
|
159963
159975
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159964
159976
|
});
|
|
159965
|
-
var
|
|
159966
|
-
|
|
159967
|
-
});
|
|
159977
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159978
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159968
159979
|
var modifiers = modifierFlags
|
|
159969
159980
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159970
159981
|
: undefined;
|
|
159971
159982
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159972
159983
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159973
159984
|
: undefined;
|
|
159974
|
-
var typeParameters = isJs
|
|
159975
|
-
|
|
159976
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159977
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159978
|
-
});
|
|
159979
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159985
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159986
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159980
159987
|
var type = isJs || contextualType === undefined
|
|
159981
159988
|
? undefined
|
|
159982
159989
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -159994,6 +160001,23 @@ var ts;
|
|
|
159994
160001
|
}
|
|
159995
160002
|
}
|
|
159996
160003
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
160004
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
160005
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
160006
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
160007
|
+
if (typeArguments) {
|
|
160008
|
+
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); }); });
|
|
160009
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
160010
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
160011
|
+
usedNames.add(createTypeParameterName(i));
|
|
160012
|
+
}
|
|
160013
|
+
}
|
|
160014
|
+
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); });
|
|
160015
|
+
}
|
|
160016
|
+
function createTypeParameterName(index) {
|
|
160017
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
160018
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
160019
|
+
: "T" + index;
|
|
160020
|
+
}
|
|
159997
160021
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
159998
160022
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
159999
160023
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -160007,15 +160031,107 @@ var ts;
|
|
|
160007
160031
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
160008
160032
|
}
|
|
160009
160033
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
160034
|
+
function typeContainsTypeParameter(type) {
|
|
160035
|
+
if (type.isUnionOrIntersection()) {
|
|
160036
|
+
return type.types.some(typeContainsTypeParameter);
|
|
160037
|
+
}
|
|
160038
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
160039
|
+
}
|
|
160040
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
160041
|
+
// Types to be used as the types of the parameters in the new function
|
|
160042
|
+
// E.g. from this source:
|
|
160043
|
+
// added("", 0)
|
|
160044
|
+
// The value will look like:
|
|
160045
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
160046
|
+
// And in the output function will generate:
|
|
160047
|
+
// function added(a: string, b: number) { ... }
|
|
160048
|
+
var argumentTypeNodes = [];
|
|
160049
|
+
// Names of type parameters provided as arguments to the call
|
|
160050
|
+
// E.g. from this source:
|
|
160051
|
+
// added<T, U>(value);
|
|
160052
|
+
// The value will look like:
|
|
160053
|
+
// [
|
|
160054
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
160055
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
160056
|
+
// ]
|
|
160057
|
+
// And in the output function will generate:
|
|
160058
|
+
// function added<T, U>() { ... }
|
|
160059
|
+
var argumentTypeParameters = new ts.Map();
|
|
160060
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
160061
|
+
var instanceType = instanceTypes[i];
|
|
160062
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
160063
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
160064
|
+
// E.g. from this source:
|
|
160065
|
+
// function existing<T, U>(value: T | U & string) {
|
|
160066
|
+
// added/*1*/(value);
|
|
160067
|
+
// We don't want to output this:
|
|
160068
|
+
// function added<T>(value: T | U & string) { ... }
|
|
160069
|
+
// We instead want to output:
|
|
160070
|
+
// function added<T>(value: T) { ... }
|
|
160071
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
160072
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
160073
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
160074
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
160075
|
+
continue;
|
|
160076
|
+
}
|
|
160077
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
160078
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
160079
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
160080
|
+
if (!argumentTypeNode) {
|
|
160081
|
+
continue;
|
|
160082
|
+
}
|
|
160083
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
160084
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
160085
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
160086
|
+
// remember that constraint for when we create the new type parameter
|
|
160087
|
+
// E.g. from this source:
|
|
160088
|
+
// function existing<T extends string>(value: T) {
|
|
160089
|
+
// added/*1*/(value);
|
|
160090
|
+
// We don't want to output this:
|
|
160091
|
+
// function added<T>(value: T) { ... }
|
|
160092
|
+
// We instead want to output:
|
|
160093
|
+
// function added<T extends string>(value: T) { ... }
|
|
160094
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
160095
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
160096
|
+
: undefined;
|
|
160097
|
+
if (argumentTypeParameter) {
|
|
160098
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
160099
|
+
}
|
|
160100
|
+
}
|
|
160101
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
160102
|
+
}
|
|
160103
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
160104
|
+
function isAnonymousObjectConstraintType(type) {
|
|
160105
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
160106
|
+
}
|
|
160107
|
+
function getFirstTypeParameterName(type) {
|
|
160108
|
+
var _a;
|
|
160109
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
160110
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
160111
|
+
var subType = _b[_i];
|
|
160112
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
160113
|
+
if (subTypeName) {
|
|
160114
|
+
return subTypeName;
|
|
160115
|
+
}
|
|
160116
|
+
}
|
|
160117
|
+
}
|
|
160118
|
+
return type.flags & 262144 /* TypeParameter */
|
|
160119
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
160120
|
+
: undefined;
|
|
160121
|
+
}
|
|
160010
160122
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
160011
160123
|
var parameters = [];
|
|
160124
|
+
var parameterNameCounts = new ts.Map();
|
|
160012
160125
|
for (var i = 0; i < argCount; i++) {
|
|
160126
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
160127
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
160128
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
160013
160129
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
160014
160130
|
/*modifiers*/ undefined,
|
|
160015
160131
|
/*dotDotDotToken*/ undefined,
|
|
160016
|
-
/*name*/
|
|
160132
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
160017
160133
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
160018
|
-
/*type*/ inJs ? undefined : types
|
|
160134
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
160019
160135
|
/*initializer*/ undefined);
|
|
160020
160136
|
parameters.push(newParameter);
|
|
160021
160137
|
}
|
|
@@ -164147,7 +164263,7 @@ var ts;
|
|
|
164147
164263
|
var usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
164148
164264
|
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
|
|
164149
164265
|
var extension = ts.extensionFromPath(oldFile.fileName);
|
|
164150
|
-
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
|
|
164266
|
+
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host);
|
|
164151
164267
|
var newFileNameWithExtension = newModuleName + extension;
|
|
164152
164268
|
// If previous file was global, this is easy.
|
|
164153
164269
|
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences));
|
|
@@ -164511,8 +164627,8 @@ var ts;
|
|
|
164511
164627
|
newModuleName = moduleName + "." + i;
|
|
164512
164628
|
}
|
|
164513
164629
|
}
|
|
164514
|
-
function getNewModuleName(movedSymbols) {
|
|
164515
|
-
return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile";
|
|
164630
|
+
function getNewModuleName(importsFromNewFile, movedSymbols) {
|
|
164631
|
+
return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile";
|
|
164516
164632
|
}
|
|
164517
164633
|
function getUsageInfo(oldFile, toMove, checker) {
|
|
164518
164634
|
var movedSymbols = new SymbolSet();
|