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
|
@@ -19,23 +19,112 @@ and limitations under the License.
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
interface ProxyHandler<T extends object> {
|
|
22
|
+
/**
|
|
23
|
+
* A trap method for a function call.
|
|
24
|
+
* @param target The original callable object which is being proxied.
|
|
25
|
+
*/
|
|
22
26
|
apply?(target: T, thisArg: any, argArray: any[]): any;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A trap for the `new` operator.
|
|
30
|
+
* @param target The original object which is being proxied.
|
|
31
|
+
* @param newTarget The constructor that was originally called.
|
|
32
|
+
*/
|
|
23
33
|
construct?(target: T, argArray: any[], newTarget: Function): object;
|
|
24
|
-
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A trap for `Object.defineProperty()`.
|
|
37
|
+
* @param target The original object which is being proxied.
|
|
38
|
+
* @returns A `Boolean` indicating whether or not the property has been defined.
|
|
39
|
+
*/
|
|
40
|
+
defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A trap for the `delete` operator.
|
|
44
|
+
* @param target The original object which is being proxied.
|
|
45
|
+
* @param p The name or `Symbol` of the property to delete.
|
|
46
|
+
* @returns A `Boolean` indicating whether or not the property was deleted.
|
|
47
|
+
*/
|
|
25
48
|
deleteProperty?(target: T, p: string | symbol): boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A trap for getting a property value.
|
|
52
|
+
* @param target The original object which is being proxied.
|
|
53
|
+
* @param p The name or `Symbol` of the property to get.
|
|
54
|
+
* @param receiver The proxy or an object that inherits from the proxy.
|
|
55
|
+
*/
|
|
26
56
|
get?(target: T, p: string | symbol, receiver: any): any;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A trap for `Object.getOwnPropertyDescriptor()`.
|
|
60
|
+
* @param target The original object which is being proxied.
|
|
61
|
+
* @param p The name of the property whose description should be retrieved.
|
|
62
|
+
*/
|
|
27
63
|
getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A trap for the `[[GetPrototypeOf]]` internal method.
|
|
67
|
+
* @param target The original object which is being proxied.
|
|
68
|
+
*/
|
|
28
69
|
getPrototypeOf?(target: T): object | null;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A trap for the `in` operator.
|
|
73
|
+
* @param target The original object which is being proxied.
|
|
74
|
+
* @param p The name or `Symbol` of the property to check for existence.
|
|
75
|
+
*/
|
|
29
76
|
has?(target: T, p: string | symbol): boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A trap for `Object.isExtensible()`.
|
|
80
|
+
* @param target The original object which is being proxied.
|
|
81
|
+
*/
|
|
30
82
|
isExtensible?(target: T): boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A trap for `Reflect.ownKeys()`.
|
|
86
|
+
* @param target The original object which is being proxied.
|
|
87
|
+
*/
|
|
31
88
|
ownKeys?(target: T): ArrayLike<string | symbol>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A trap for `Object.preventExtensions()`.
|
|
92
|
+
* @param target The original object which is being proxied.
|
|
93
|
+
*/
|
|
32
94
|
preventExtensions?(target: T): boolean;
|
|
33
|
-
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A trap for setting a property value.
|
|
98
|
+
* @param target The original object which is being proxied.
|
|
99
|
+
* @param p The name or `Symbol` of the property to set.
|
|
100
|
+
* @param receiver The object to which the assignment was originally directed.
|
|
101
|
+
* @returns `A `Boolean` indicating whether or not the property was set.
|
|
102
|
+
*/
|
|
103
|
+
set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A trap for `Object.setPrototypeOf()`.
|
|
107
|
+
* @param target The original object which is being proxied.
|
|
108
|
+
* @param newPrototype The object's new prototype or `null`.
|
|
109
|
+
*/
|
|
34
110
|
setPrototypeOf?(target: T, v: object | null): boolean;
|
|
35
111
|
}
|
|
36
112
|
|
|
37
113
|
interface ProxyConstructor {
|
|
114
|
+
/**
|
|
115
|
+
* Creates a revocable Proxy object.
|
|
116
|
+
* @param target A target object to wrap with Proxy.
|
|
117
|
+
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
|
118
|
+
*/
|
|
38
119
|
revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the
|
|
123
|
+
* original object, but which may redefine fundamental Object operations like getting, setting, and defining
|
|
124
|
+
* properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.
|
|
125
|
+
* @param target A target object to wrap with Proxy.
|
|
126
|
+
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
|
127
|
+
*/
|
|
39
128
|
new <T extends object>(target: T, handler: ProxyHandler<T>): T;
|
|
40
129
|
}
|
|
41
130
|
declare var Proxy: ProxyConstructor;
|
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.8";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220728";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
@@ -5731,6 +5731,7 @@ var ts;
|
|
|
5731
5731
|
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."),
|
|
5732
5732
|
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."),
|
|
5733
5733
|
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."),
|
|
5734
|
+
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
5734
5735
|
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."),
|
|
5735
5736
|
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."),
|
|
5736
5737
|
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.", undefined, true),
|
|
@@ -26880,7 +26881,9 @@ var ts;
|
|
|
26880
26881
|
case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
26881
26882
|
case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
26882
26883
|
case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
|
|
26883
|
-
|
|
26884
|
+
case 24: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected);
|
|
26885
|
+
case 25: return ts.Debug.fail("ParsingContext.Count used as a context");
|
|
26886
|
+
default: ts.Debug.assertNever(context);
|
|
26884
26887
|
}
|
|
26885
26888
|
}
|
|
26886
26889
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
@@ -27226,7 +27229,7 @@ var ts;
|
|
|
27226
27229
|
if (allowAmbiguity === void 0) { allowAmbiguity = true; }
|
|
27227
27230
|
var pos = getNodePos();
|
|
27228
27231
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
27229
|
-
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators
|
|
27232
|
+
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
|
|
27230
27233
|
if (token() === 108) {
|
|
27231
27234
|
var node_1 = factory.createParameterDeclaration(decorators, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined);
|
|
27232
27235
|
if (decorators) {
|
|
@@ -49226,7 +49229,7 @@ var ts;
|
|
|
49226
49229
|
}
|
|
49227
49230
|
}
|
|
49228
49231
|
}
|
|
49229
|
-
return getIntersectionType(constraints);
|
|
49232
|
+
return getNormalizedType(getIntersectionType(constraints), false);
|
|
49230
49233
|
}
|
|
49231
49234
|
return undefined;
|
|
49232
49235
|
}
|
|
@@ -60178,7 +60181,9 @@ var ts;
|
|
|
60178
60181
|
var narrowedType = mapType(candidate, function (c) {
|
|
60179
60182
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
60180
60183
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
60181
|
-
var directlyRelated = mapType(matching || type,
|
|
60184
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
60185
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
60186
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
60182
60187
|
return directlyRelated.flags & 131072 ?
|
|
60183
60188
|
mapType(type, function (t) { return maybeTypeOfKind(t, 465829888) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) :
|
|
60184
60189
|
directlyRelated;
|
|
@@ -70963,14 +70968,19 @@ var ts;
|
|
|
70963
70968
|
}
|
|
70964
70969
|
var indexInfos = getApplicableIndexInfos(type, propNameType);
|
|
70965
70970
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
|
|
70966
|
-
var
|
|
70967
|
-
name && name.kind === 162
|
|
70971
|
+
var propDeclaration = declaration && declaration.kind === 221 ||
|
|
70972
|
+
name && name.kind === 162 ? declaration : undefined;
|
|
70973
|
+
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
70968
70974
|
var _loop_30 = function (info) {
|
|
70969
70975
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
70970
70976
|
var errorNode = localPropDeclaration || localIndexDeclaration ||
|
|
70971
70977
|
(interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
|
|
70972
70978
|
if (errorNode && !isTypeAssignableTo(propType, info.type)) {
|
|
70973
|
-
|
|
70979
|
+
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));
|
|
70980
|
+
if (propDeclaration && errorNode !== propDeclaration) {
|
|
70981
|
+
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
|
|
70982
|
+
}
|
|
70983
|
+
diagnostics.add(diagnostic);
|
|
70974
70984
|
}
|
|
70975
70985
|
};
|
|
70976
70986
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
@@ -76310,7 +76320,7 @@ var ts;
|
|
|
76310
76320
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
76311
76321
|
case 197:
|
|
76312
76322
|
ts.Debug.type(node);
|
|
76313
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
76323
|
+
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));
|
|
76314
76324
|
case 191:
|
|
76315
76325
|
ts.Debug.type(node);
|
|
76316
76326
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
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.20220728";
|
|
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),
|
|
@@ -59422,7 +59425,8 @@ var ts;
|
|
|
59422
59425
|
}
|
|
59423
59426
|
}
|
|
59424
59427
|
}
|
|
59425
|
-
|
|
59428
|
+
// The source types were normalized; ensure the result is normalized too.
|
|
59429
|
+
return getNormalizedType(getIntersectionType(constraints), /*writing*/ false);
|
|
59426
59430
|
}
|
|
59427
59431
|
return undefined;
|
|
59428
59432
|
}
|
|
@@ -71948,8 +71952,12 @@ var ts;
|
|
|
71948
71952
|
var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
|
|
71949
71953
|
var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
|
|
71950
71954
|
// For each constituent t in the current type, if t and and c are directly related, pick the most
|
|
71951
|
-
// specific of the two.
|
|
71952
|
-
|
|
71955
|
+
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
|
|
71956
|
+
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
|
|
71957
|
+
// prototype object types.
|
|
71958
|
+
var directlyRelated = mapType(matching || type, checkDerived ?
|
|
71959
|
+
function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
|
|
71960
|
+
function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
|
|
71953
71961
|
// If no constituents are directly related, create intersections for any generic constituents that
|
|
71954
71962
|
// are related by constraint.
|
|
71955
71963
|
return directlyRelated.flags & 131072 /* Never */ ?
|
|
@@ -84661,8 +84669,9 @@ var ts;
|
|
|
84661
84669
|
}
|
|
84662
84670
|
var indexInfos = getApplicableIndexInfos(type, propNameType);
|
|
84663
84671
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
84664
|
-
var
|
|
84665
|
-
name && name.kind === 162 /* ComputedPropertyName */
|
|
84672
|
+
var propDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
|
|
84673
|
+
name && name.kind === 162 /* ComputedPropertyName */ ? declaration : undefined;
|
|
84674
|
+
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
84666
84675
|
var _loop_30 = function (info) {
|
|
84667
84676
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
84668
84677
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
@@ -84671,7 +84680,11 @@ var ts;
|
|
|
84671
84680
|
var errorNode = localPropDeclaration || localIndexDeclaration ||
|
|
84672
84681
|
(interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
|
|
84673
84682
|
if (errorNode && !isTypeAssignableTo(propType, info.type)) {
|
|
84674
|
-
|
|
84683
|
+
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));
|
|
84684
|
+
if (propDeclaration && errorNode !== propDeclaration) {
|
|
84685
|
+
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
|
|
84686
|
+
}
|
|
84687
|
+
diagnostics.add(diagnostic);
|
|
84675
84688
|
}
|
|
84676
84689
|
};
|
|
84677
84690
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
@@ -90568,7 +90581,7 @@ var ts;
|
|
|
90568
90581
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90569
90582
|
case 197 /* NamedTupleMember */:
|
|
90570
90583
|
ts.Debug.type(node);
|
|
90571
|
-
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken,
|
|
90584
|
+
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));
|
|
90572
90585
|
case 191 /* ParenthesizedType */:
|
|
90573
90586
|
ts.Debug.type(node);
|
|
90574
90587
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -118322,7 +118335,7 @@ var ts;
|
|
|
118322
118335
|
// `result[i]` is either a `ResolvedModuleFull` or a marker.
|
|
118323
118336
|
// If it is the former, we can leave it as is.
|
|
118324
118337
|
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
|
118325
|
-
result[i] = undefined;
|
|
118338
|
+
result[i] = undefined;
|
|
118326
118339
|
}
|
|
118327
118340
|
}
|
|
118328
118341
|
else {
|
|
@@ -155389,8 +155402,7 @@ var ts;
|
|
|
155389
155402
|
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155390
155403
|
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155391
155404
|
if (info) {
|
|
155392
|
-
|
|
155393
|
-
if (ts.addToSeen(seen, id)) {
|
|
155405
|
+
if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) {
|
|
155394
155406
|
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
155395
155407
|
}
|
|
155396
155408
|
}
|
|
@@ -159358,21 +159370,16 @@ var ts;
|
|
|
159358
159370
|
var names = ts.map(args, function (arg) {
|
|
159359
159371
|
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
|
|
159360
159372
|
});
|
|
159361
|
-
var
|
|
159362
|
-
|
|
159363
|
-
});
|
|
159373
|
+
var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); });
|
|
159374
|
+
var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters;
|
|
159364
159375
|
var modifiers = modifierFlags
|
|
159365
159376
|
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
|
|
159366
159377
|
: undefined;
|
|
159367
159378
|
var asteriskToken = ts.isYieldExpression(parent)
|
|
159368
159379
|
? ts.factory.createToken(41 /* AsteriskToken */)
|
|
159369
159380
|
: undefined;
|
|
159370
|
-
var typeParameters = isJs
|
|
159371
|
-
|
|
159372
|
-
: ts.map(typeArguments, function (_, i) {
|
|
159373
|
-
return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
|
|
159374
|
-
});
|
|
159375
|
-
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
|
159381
|
+
var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
|
159382
|
+
var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
|
159376
159383
|
var type = isJs || contextualType === undefined
|
|
159377
159384
|
? undefined
|
|
159378
159385
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
@@ -159390,6 +159397,23 @@ var ts;
|
|
|
159390
159397
|
}
|
|
159391
159398
|
}
|
|
159392
159399
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
159400
|
+
function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) {
|
|
159401
|
+
var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; }));
|
|
159402
|
+
var constraintsByName = new ts.Map(argumentTypeParameters);
|
|
159403
|
+
if (typeArguments) {
|
|
159404
|
+
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); }); });
|
|
159405
|
+
var targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
|
159406
|
+
for (var i = 0; usedNames.size < targetSize; i += 1) {
|
|
159407
|
+
usedNames.add(createTypeParameterName(i));
|
|
159408
|
+
}
|
|
159409
|
+
}
|
|
159410
|
+
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); });
|
|
159411
|
+
}
|
|
159412
|
+
function createTypeParameterName(index) {
|
|
159413
|
+
return 84 /* T */ + index <= 90 /* Z */
|
|
159414
|
+
? String.fromCharCode(84 /* T */ + index)
|
|
159415
|
+
: "T" + index;
|
|
159416
|
+
}
|
|
159393
159417
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
159394
159418
|
var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
|
159395
159419
|
if (typeNode && ts.isImportTypeNode(typeNode)) {
|
|
@@ -159403,15 +159427,107 @@ var ts;
|
|
|
159403
159427
|
return ts.getSynthesizedDeepClone(typeNode);
|
|
159404
159428
|
}
|
|
159405
159429
|
codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
|
|
159430
|
+
function typeContainsTypeParameter(type) {
|
|
159431
|
+
if (type.isUnionOrIntersection()) {
|
|
159432
|
+
return type.types.some(typeContainsTypeParameter);
|
|
159433
|
+
}
|
|
159434
|
+
return type.flags & 262144 /* TypeParameter */;
|
|
159435
|
+
}
|
|
159436
|
+
function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) {
|
|
159437
|
+
// Types to be used as the types of the parameters in the new function
|
|
159438
|
+
// E.g. from this source:
|
|
159439
|
+
// added("", 0)
|
|
159440
|
+
// The value will look like:
|
|
159441
|
+
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
|
159442
|
+
// And in the output function will generate:
|
|
159443
|
+
// function added(a: string, b: number) { ... }
|
|
159444
|
+
var argumentTypeNodes = [];
|
|
159445
|
+
// Names of type parameters provided as arguments to the call
|
|
159446
|
+
// E.g. from this source:
|
|
159447
|
+
// added<T, U>(value);
|
|
159448
|
+
// The value will look like:
|
|
159449
|
+
// [
|
|
159450
|
+
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
|
159451
|
+
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
|
159452
|
+
// ]
|
|
159453
|
+
// And in the output function will generate:
|
|
159454
|
+
// function added<T, U>() { ... }
|
|
159455
|
+
var argumentTypeParameters = new ts.Map();
|
|
159456
|
+
for (var i = 0; i < instanceTypes.length; i += 1) {
|
|
159457
|
+
var instanceType = instanceTypes[i];
|
|
159458
|
+
// If the instance type contains a deep reference to an existing type parameter,
|
|
159459
|
+
// instead of copying the full union or intersection, create a new type parameter
|
|
159460
|
+
// E.g. from this source:
|
|
159461
|
+
// function existing<T, U>(value: T | U & string) {
|
|
159462
|
+
// added/*1*/(value);
|
|
159463
|
+
// We don't want to output this:
|
|
159464
|
+
// function added<T>(value: T | U & string) { ... }
|
|
159465
|
+
// We instead want to output:
|
|
159466
|
+
// function added<T>(value: T) { ... }
|
|
159467
|
+
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
|
159468
|
+
var synthesizedTypeParameterName = createTypeParameterName(i);
|
|
159469
|
+
argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
|
159470
|
+
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
|
159471
|
+
continue;
|
|
159472
|
+
}
|
|
159473
|
+
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
|
159474
|
+
var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
|
159475
|
+
var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
|
159476
|
+
if (!argumentTypeNode) {
|
|
159477
|
+
continue;
|
|
159478
|
+
}
|
|
159479
|
+
argumentTypeNodes.push(argumentTypeNode);
|
|
159480
|
+
var argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
|
159481
|
+
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
|
159482
|
+
// remember that constraint for when we create the new type parameter
|
|
159483
|
+
// E.g. from this source:
|
|
159484
|
+
// function existing<T extends string>(value: T) {
|
|
159485
|
+
// added/*1*/(value);
|
|
159486
|
+
// We don't want to output this:
|
|
159487
|
+
// function added<T>(value: T) { ... }
|
|
159488
|
+
// We instead want to output:
|
|
159489
|
+
// function added<T extends string>(value: T) { ... }
|
|
159490
|
+
var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
|
159491
|
+
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
|
159492
|
+
: undefined;
|
|
159493
|
+
if (argumentTypeParameter) {
|
|
159494
|
+
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
|
159495
|
+
}
|
|
159496
|
+
}
|
|
159497
|
+
return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) };
|
|
159498
|
+
}
|
|
159499
|
+
codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters;
|
|
159500
|
+
function isAnonymousObjectConstraintType(type) {
|
|
159501
|
+
return (type.flags & 524288 /* Object */) && type.objectFlags === 16 /* Anonymous */;
|
|
159502
|
+
}
|
|
159503
|
+
function getFirstTypeParameterName(type) {
|
|
159504
|
+
var _a;
|
|
159505
|
+
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
159506
|
+
for (var _i = 0, _b = type.types; _i < _b.length; _i++) {
|
|
159507
|
+
var subType = _b[_i];
|
|
159508
|
+
var subTypeName = getFirstTypeParameterName(subType);
|
|
159509
|
+
if (subTypeName) {
|
|
159510
|
+
return subTypeName;
|
|
159511
|
+
}
|
|
159512
|
+
}
|
|
159513
|
+
}
|
|
159514
|
+
return type.flags & 262144 /* TypeParameter */
|
|
159515
|
+
? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName()
|
|
159516
|
+
: undefined;
|
|
159517
|
+
}
|
|
159406
159518
|
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
|
|
159407
159519
|
var parameters = [];
|
|
159520
|
+
var parameterNameCounts = new ts.Map();
|
|
159408
159521
|
for (var i = 0; i < argCount; i++) {
|
|
159522
|
+
var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg" + i;
|
|
159523
|
+
var parameterNameCount = parameterNameCounts.get(parameterName);
|
|
159524
|
+
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
|
159409
159525
|
var newParameter = ts.factory.createParameterDeclaration(
|
|
159410
159526
|
/*modifiers*/ undefined,
|
|
159411
159527
|
/*dotDotDotToken*/ undefined,
|
|
159412
|
-
/*name*/
|
|
159528
|
+
/*name*/ parameterName + (parameterNameCount || ""),
|
|
159413
159529
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
159414
|
-
/*type*/ inJs ? undefined : types
|
|
159530
|
+
/*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */),
|
|
159415
159531
|
/*initializer*/ undefined);
|
|
159416
159532
|
parameters.push(newParameter);
|
|
159417
159533
|
}
|
|
@@ -163543,7 +163659,7 @@ var ts;
|
|
|
163543
163659
|
var usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
163544
163660
|
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
|
|
163545
163661
|
var extension = ts.extensionFromPath(oldFile.fileName);
|
|
163546
|
-
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
|
|
163662
|
+
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host);
|
|
163547
163663
|
var newFileNameWithExtension = newModuleName + extension;
|
|
163548
163664
|
// If previous file was global, this is easy.
|
|
163549
163665
|
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences));
|
|
@@ -163907,8 +164023,8 @@ var ts;
|
|
|
163907
164023
|
newModuleName = moduleName + "." + i;
|
|
163908
164024
|
}
|
|
163909
164025
|
}
|
|
163910
|
-
function getNewModuleName(movedSymbols) {
|
|
163911
|
-
return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile";
|
|
164026
|
+
function getNewModuleName(importsFromNewFile, movedSymbols) {
|
|
164027
|
+
return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile";
|
|
163912
164028
|
}
|
|
163913
164029
|
function getUsageInfo(oldFile, toMove, checker) {
|
|
163914
164030
|
var movedSymbols = new SymbolSet();
|