typescript 5.2.0-dev.20230605 → 5.2.0-dev.20230606
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/tsc.js +35 -25
- package/lib/tsserver.js +54 -28
- package/lib/tsserverlibrary.js +54 -28
- package/lib/typescript.js +54 -28
- package/lib/typingsInstaller.js +6 -5
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.2";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20230606`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -42658,10 +42658,11 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
42658
42658
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
42659
42659
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
42660
42660
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
42661
|
-
CheckMode3[CheckMode3["
|
|
42662
|
-
CheckMode3[CheckMode3["
|
|
42663
|
-
CheckMode3[CheckMode3["
|
|
42664
|
-
CheckMode3[CheckMode3["
|
|
42661
|
+
CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
|
|
42662
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
|
|
42663
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
|
|
42664
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
|
|
42665
|
+
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
42665
42666
|
return CheckMode3;
|
|
42666
42667
|
})(CheckMode || {});
|
|
42667
42668
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -42941,9 +42942,9 @@ function createTypeChecker(host) {
|
|
|
42941
42942
|
candidatesOutArray,
|
|
42942
42943
|
/*argumentCount*/
|
|
42943
42944
|
void 0,
|
|
42944
|
-
|
|
42945
|
+
64 /* IsForStringLiteralArgumentCompletions */
|
|
42945
42946
|
)),
|
|
42946
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
42947
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
|
|
42947
42948
|
getExpandedParameters,
|
|
42948
42949
|
hasEffectiveRestParameter,
|
|
42949
42950
|
containsArgumentsReference,
|
|
@@ -50898,7 +50899,7 @@ function createTypeChecker(host) {
|
|
|
50898
50899
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
50899
50900
|
}
|
|
50900
50901
|
function getTypeForBindingElement(declaration) {
|
|
50901
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
50902
|
+
const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
50902
50903
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
50903
50904
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
50904
50905
|
}
|
|
@@ -58096,7 +58097,10 @@ function createTypeChecker(host) {
|
|
|
58096
58097
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
58097
58098
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
58098
58099
|
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
58099
|
-
|
|
58100
|
+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
58101
|
+
if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
58102
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
58103
|
+
}
|
|
58100
58104
|
}
|
|
58101
58105
|
target.instantiations.set(id, result);
|
|
58102
58106
|
}
|
|
@@ -65795,7 +65799,7 @@ function createTypeChecker(host) {
|
|
|
65795
65799
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
65796
65800
|
}
|
|
65797
65801
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
65798
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
65802
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
|
|
65799
65803
|
node,
|
|
65800
65804
|
/*contextFlags*/
|
|
65801
65805
|
void 0
|
|
@@ -66552,7 +66556,7 @@ function createTypeChecker(host) {
|
|
|
66552
66556
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
66553
66557
|
const parent = declaration.parent.parent;
|
|
66554
66558
|
const name = declaration.propertyName || declaration.name;
|
|
66555
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
66559
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
|
|
66556
66560
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
66557
66561
|
return void 0;
|
|
66558
66562
|
if (parent.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -67601,7 +67605,9 @@ function createTypeChecker(host) {
|
|
|
67601
67605
|
elementTypes.push(undefinedOrMissingType);
|
|
67602
67606
|
elementFlags.push(2 /* Optional */);
|
|
67603
67607
|
} else {
|
|
67604
|
-
const
|
|
67608
|
+
const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
|
|
67609
|
+
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
67610
|
+
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
67605
67611
|
elementTypes.push(addOptionality(
|
|
67606
67612
|
type,
|
|
67607
67613
|
/*isProperty*/
|
|
@@ -67609,7 +67615,7 @@ function createTypeChecker(host) {
|
|
|
67609
67615
|
hasOmittedExpression
|
|
67610
67616
|
));
|
|
67611
67617
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
67612
|
-
if (
|
|
67618
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
67613
67619
|
const inferenceContext = getInferenceContext(node);
|
|
67614
67620
|
Debug.assert(inferenceContext);
|
|
67615
67621
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -67750,11 +67756,13 @@ function createTypeChecker(host) {
|
|
|
67750
67756
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
67751
67757
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
67752
67758
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
67753
|
-
|
|
67759
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
67760
|
+
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
67761
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
67754
67762
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
67755
67763
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
67756
67764
|
// we don't want to say "could not find 'a'".
|
|
67757
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
67765
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
|
|
67758
67766
|
);
|
|
67759
67767
|
if (isInJavascript) {
|
|
67760
67768
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -67798,7 +67806,7 @@ function createTypeChecker(host) {
|
|
|
67798
67806
|
prop.links.target = member;
|
|
67799
67807
|
member = prop;
|
|
67800
67808
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
67801
|
-
if (
|
|
67809
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
67802
67810
|
const inferenceContext = getInferenceContext(node);
|
|
67803
67811
|
Debug.assert(inferenceContext);
|
|
67804
67812
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -67971,7 +67979,9 @@ function createTypeChecker(host) {
|
|
|
67971
67979
|
for (const attributeDecl of attributes.properties) {
|
|
67972
67980
|
const member = attributeDecl.symbol;
|
|
67973
67981
|
if (isJsxAttribute(attributeDecl)) {
|
|
67974
|
-
const
|
|
67982
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
|
|
67983
|
+
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
67984
|
+
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
67975
67985
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
67976
67986
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
67977
67987
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -67992,7 +68002,7 @@ function createTypeChecker(host) {
|
|
|
67992
68002
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
67993
68003
|
}
|
|
67994
68004
|
}
|
|
67995
|
-
if (
|
|
68005
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
67996
68006
|
const inferenceContext = getInferenceContext(attributes);
|
|
67997
68007
|
Debug.assert(inferenceContext);
|
|
67998
68008
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -69610,7 +69620,7 @@ function createTypeChecker(host) {
|
|
|
69610
69620
|
}
|
|
69611
69621
|
for (let i = 0; i < argCount; i++) {
|
|
69612
69622
|
const arg = args[i];
|
|
69613
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
69623
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
69614
69624
|
const paramType = getTypeAtPosition(signature, i);
|
|
69615
69625
|
if (couldContainTypeVariables(paramType)) {
|
|
69616
69626
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -70223,12 +70233,12 @@ function createTypeChecker(host) {
|
|
|
70223
70233
|
const args = getEffectiveCallArguments(node);
|
|
70224
70234
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
70225
70235
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
70226
|
-
argCheckMode |= checkMode &
|
|
70236
|
+
argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
70227
70237
|
let candidatesForArgumentError;
|
|
70228
70238
|
let candidateForArgumentArityError;
|
|
70229
70239
|
let candidateForTypeArgumentError;
|
|
70230
70240
|
let result;
|
|
70231
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
70241
|
+
const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
70232
70242
|
if (candidates.length > 1) {
|
|
70233
70243
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
70234
70244
|
}
|
|
@@ -70447,7 +70457,7 @@ function createTypeChecker(host) {
|
|
|
70447
70457
|
continue;
|
|
70448
70458
|
}
|
|
70449
70459
|
if (argCheckMode) {
|
|
70450
|
-
argCheckMode = checkMode &
|
|
70460
|
+
argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
70451
70461
|
if (inferenceContext) {
|
|
70452
70462
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
70453
70463
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -73525,7 +73535,7 @@ function createTypeChecker(host) {
|
|
|
73525
73535
|
case 36 /* ExclamationEqualsToken */:
|
|
73526
73536
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
73527
73537
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
73528
|
-
if (!(checkMode && checkMode &
|
|
73538
|
+
if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
|
|
73529
73539
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
73530
73540
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
73531
73541
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -74184,7 +74194,7 @@ function createTypeChecker(host) {
|
|
|
74184
74194
|
}
|
|
74185
74195
|
}
|
|
74186
74196
|
const startInvocationCount = flowInvocationCount;
|
|
74187
|
-
const type = checkExpression(node,
|
|
74197
|
+
const type = checkExpression(node, 256 /* TypeOnly */);
|
|
74188
74198
|
if (flowInvocationCount !== startInvocationCount) {
|
|
74189
74199
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
74190
74200
|
cache[getNodeId(node)] = type;
|
|
@@ -76655,7 +76665,7 @@ function createTypeChecker(host) {
|
|
|
76655
76665
|
checkComputedPropertyName(node.propertyName);
|
|
76656
76666
|
}
|
|
76657
76667
|
const parent = node.parent.parent;
|
|
76658
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
76668
|
+
const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
76659
76669
|
const parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
76660
76670
|
const name = node.propertyName || node.name;
|
|
76661
76671
|
if (parentType && !isBindingPattern(name)) {
|
package/lib/tsserver.js
CHANGED
|
@@ -2304,7 +2304,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2304
2304
|
|
|
2305
2305
|
// src/compiler/corePublic.ts
|
|
2306
2306
|
var versionMajorMinor = "5.2";
|
|
2307
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2307
|
+
var version = `${versionMajorMinor}.0-dev.20230606`;
|
|
2308
2308
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2309
2309
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2310
2310
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -47309,10 +47309,11 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
47309
47309
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
47310
47310
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47311
47311
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47312
|
-
CheckMode3[CheckMode3["
|
|
47313
|
-
CheckMode3[CheckMode3["
|
|
47314
|
-
CheckMode3[CheckMode3["
|
|
47315
|
-
CheckMode3[CheckMode3["
|
|
47312
|
+
CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
|
|
47313
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
|
|
47314
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
|
|
47315
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
|
|
47316
|
+
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
47316
47317
|
return CheckMode3;
|
|
47317
47318
|
})(CheckMode || {});
|
|
47318
47319
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -47592,9 +47593,9 @@ function createTypeChecker(host) {
|
|
|
47592
47593
|
candidatesOutArray,
|
|
47593
47594
|
/*argumentCount*/
|
|
47594
47595
|
void 0,
|
|
47595
|
-
|
|
47596
|
+
64 /* IsForStringLiteralArgumentCompletions */
|
|
47596
47597
|
)),
|
|
47597
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
47598
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
|
|
47598
47599
|
getExpandedParameters,
|
|
47599
47600
|
hasEffectiveRestParameter,
|
|
47600
47601
|
containsArgumentsReference,
|
|
@@ -55549,7 +55550,7 @@ function createTypeChecker(host) {
|
|
|
55549
55550
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
55550
55551
|
}
|
|
55551
55552
|
function getTypeForBindingElement(declaration) {
|
|
55552
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
55553
|
+
const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
55553
55554
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55554
55555
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55555
55556
|
}
|
|
@@ -62747,7 +62748,10 @@ function createTypeChecker(host) {
|
|
|
62747
62748
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
62748
62749
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
62749
62750
|
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62750
|
-
|
|
62751
|
+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
62752
|
+
if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62753
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
62754
|
+
}
|
|
62751
62755
|
}
|
|
62752
62756
|
target.instantiations.set(id, result);
|
|
62753
62757
|
}
|
|
@@ -70446,7 +70450,7 @@ function createTypeChecker(host) {
|
|
|
70446
70450
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
70447
70451
|
}
|
|
70448
70452
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70449
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
70453
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
70450
70454
|
node,
|
|
70451
70455
|
/*contextFlags*/
|
|
70452
70456
|
void 0
|
|
@@ -71203,7 +71207,7 @@ function createTypeChecker(host) {
|
|
|
71203
71207
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
71204
71208
|
const parent2 = declaration.parent.parent;
|
|
71205
71209
|
const name = declaration.propertyName || declaration.name;
|
|
71206
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
71210
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
|
|
71207
71211
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
71208
71212
|
return void 0;
|
|
71209
71213
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -72252,7 +72256,9 @@ function createTypeChecker(host) {
|
|
|
72252
72256
|
elementTypes.push(undefinedOrMissingType);
|
|
72253
72257
|
elementFlags.push(2 /* Optional */);
|
|
72254
72258
|
} else {
|
|
72255
|
-
const
|
|
72259
|
+
const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
|
|
72260
|
+
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72261
|
+
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
72256
72262
|
elementTypes.push(addOptionality(
|
|
72257
72263
|
type,
|
|
72258
72264
|
/*isProperty*/
|
|
@@ -72260,7 +72266,7 @@ function createTypeChecker(host) {
|
|
|
72260
72266
|
hasOmittedExpression
|
|
72261
72267
|
));
|
|
72262
72268
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72263
|
-
if (
|
|
72269
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
72264
72270
|
const inferenceContext = getInferenceContext(node);
|
|
72265
72271
|
Debug.assert(inferenceContext);
|
|
72266
72272
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -72401,11 +72407,13 @@ function createTypeChecker(host) {
|
|
|
72401
72407
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
72402
72408
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
72403
72409
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
72404
|
-
|
|
72410
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
72411
|
+
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72412
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
72405
72413
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
72406
72414
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
72407
72415
|
// we don't want to say "could not find 'a'".
|
|
72408
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
72416
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
|
|
72409
72417
|
);
|
|
72410
72418
|
if (isInJavascript) {
|
|
72411
72419
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -72449,7 +72457,7 @@ function createTypeChecker(host) {
|
|
|
72449
72457
|
prop.links.target = member;
|
|
72450
72458
|
member = prop;
|
|
72451
72459
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
72452
|
-
if (
|
|
72460
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
72453
72461
|
const inferenceContext = getInferenceContext(node);
|
|
72454
72462
|
Debug.assert(inferenceContext);
|
|
72455
72463
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -72622,7 +72630,9 @@ function createTypeChecker(host) {
|
|
|
72622
72630
|
for (const attributeDecl of attributes.properties) {
|
|
72623
72631
|
const member = attributeDecl.symbol;
|
|
72624
72632
|
if (isJsxAttribute(attributeDecl)) {
|
|
72625
|
-
const
|
|
72633
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
|
|
72634
|
+
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72635
|
+
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
72626
72636
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
72627
72637
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
72628
72638
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -72643,7 +72653,7 @@ function createTypeChecker(host) {
|
|
|
72643
72653
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
72644
72654
|
}
|
|
72645
72655
|
}
|
|
72646
|
-
if (
|
|
72656
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
72647
72657
|
const inferenceContext = getInferenceContext(attributes);
|
|
72648
72658
|
Debug.assert(inferenceContext);
|
|
72649
72659
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -74261,7 +74271,7 @@ function createTypeChecker(host) {
|
|
|
74261
74271
|
}
|
|
74262
74272
|
for (let i = 0; i < argCount; i++) {
|
|
74263
74273
|
const arg = args[i];
|
|
74264
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
74274
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74265
74275
|
const paramType = getTypeAtPosition(signature, i);
|
|
74266
74276
|
if (couldContainTypeVariables(paramType)) {
|
|
74267
74277
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -74874,12 +74884,12 @@ function createTypeChecker(host) {
|
|
|
74874
74884
|
const args = getEffectiveCallArguments(node);
|
|
74875
74885
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
74876
74886
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
74877
|
-
argCheckMode |= checkMode &
|
|
74887
|
+
argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
74878
74888
|
let candidatesForArgumentError;
|
|
74879
74889
|
let candidateForArgumentArityError;
|
|
74880
74890
|
let candidateForTypeArgumentError;
|
|
74881
74891
|
let result;
|
|
74882
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
74892
|
+
const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
74883
74893
|
if (candidates.length > 1) {
|
|
74884
74894
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
74885
74895
|
}
|
|
@@ -75098,7 +75108,7 @@ function createTypeChecker(host) {
|
|
|
75098
75108
|
continue;
|
|
75099
75109
|
}
|
|
75100
75110
|
if (argCheckMode) {
|
|
75101
|
-
argCheckMode = checkMode &
|
|
75111
|
+
argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
75102
75112
|
if (inferenceContext) {
|
|
75103
75113
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
75104
75114
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -78176,7 +78186,7 @@ function createTypeChecker(host) {
|
|
|
78176
78186
|
case 36 /* ExclamationEqualsToken */:
|
|
78177
78187
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
78178
78188
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
78179
|
-
if (!(checkMode && checkMode &
|
|
78189
|
+
if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
|
|
78180
78190
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
78181
78191
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
78182
78192
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -78835,7 +78845,7 @@ function createTypeChecker(host) {
|
|
|
78835
78845
|
}
|
|
78836
78846
|
}
|
|
78837
78847
|
const startInvocationCount = flowInvocationCount;
|
|
78838
|
-
const type = checkExpression(node,
|
|
78848
|
+
const type = checkExpression(node, 256 /* TypeOnly */);
|
|
78839
78849
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78840
78850
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
78841
78851
|
cache[getNodeId(node)] = type;
|
|
@@ -81306,7 +81316,7 @@ function createTypeChecker(host) {
|
|
|
81306
81316
|
checkComputedPropertyName(node.propertyName);
|
|
81307
81317
|
}
|
|
81308
81318
|
const parent2 = node.parent.parent;
|
|
81309
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
81319
|
+
const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
81310
81320
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
81311
81321
|
const name = node.propertyName || node.name;
|
|
81312
81322
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -162741,13 +162751,29 @@ function provideInlayHints(context) {
|
|
|
162741
162751
|
if (!signature || !candidates.length) {
|
|
162742
162752
|
return;
|
|
162743
162753
|
}
|
|
162744
|
-
|
|
162745
|
-
|
|
162754
|
+
let signatureParamPos = 0;
|
|
162755
|
+
for (const originalArg of args) {
|
|
162746
162756
|
const arg = skipParentheses(originalArg);
|
|
162747
162757
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162748
162758
|
continue;
|
|
162749
162759
|
}
|
|
162750
|
-
|
|
162760
|
+
let spreadArgs = 0;
|
|
162761
|
+
if (isSpreadElement(arg)) {
|
|
162762
|
+
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162763
|
+
if (checker.isTupleType(spreadType)) {
|
|
162764
|
+
const { elementFlags, fixedLength } = spreadType.target;
|
|
162765
|
+
if (fixedLength === 0) {
|
|
162766
|
+
continue;
|
|
162767
|
+
}
|
|
162768
|
+
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162769
|
+
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162770
|
+
if (requiredArgs > 0) {
|
|
162771
|
+
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162772
|
+
}
|
|
162773
|
+
}
|
|
162774
|
+
}
|
|
162775
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162776
|
+
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162751
162777
|
if (identifierNameInfo) {
|
|
162752
162778
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162753
162779
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.2";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230606`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -45382,9 +45382,9 @@ ${lanes.join("\n")}
|
|
|
45382
45382
|
candidatesOutArray,
|
|
45383
45383
|
/*argumentCount*/
|
|
45384
45384
|
void 0,
|
|
45385
|
-
|
|
45385
|
+
64 /* IsForStringLiteralArgumentCompletions */
|
|
45386
45386
|
)),
|
|
45387
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
45387
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
|
|
45388
45388
|
getExpandedParameters,
|
|
45389
45389
|
hasEffectiveRestParameter,
|
|
45390
45390
|
containsArgumentsReference,
|
|
@@ -53339,7 +53339,7 @@ ${lanes.join("\n")}
|
|
|
53339
53339
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
53340
53340
|
}
|
|
53341
53341
|
function getTypeForBindingElement(declaration) {
|
|
53342
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
53342
|
+
const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
53343
53343
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
53344
53344
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
53345
53345
|
}
|
|
@@ -60537,7 +60537,10 @@ ${lanes.join("\n")}
|
|
|
60537
60537
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
60538
60538
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
60539
60539
|
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
60540
|
-
|
|
60540
|
+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
60541
|
+
if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
60542
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
60543
|
+
}
|
|
60541
60544
|
}
|
|
60542
60545
|
target.instantiations.set(id, result);
|
|
60543
60546
|
}
|
|
@@ -68236,7 +68239,7 @@ ${lanes.join("\n")}
|
|
|
68236
68239
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
68237
68240
|
}
|
|
68238
68241
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
68239
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
68242
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
68240
68243
|
node,
|
|
68241
68244
|
/*contextFlags*/
|
|
68242
68245
|
void 0
|
|
@@ -68993,7 +68996,7 @@ ${lanes.join("\n")}
|
|
|
68993
68996
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
68994
68997
|
const parent2 = declaration.parent.parent;
|
|
68995
68998
|
const name = declaration.propertyName || declaration.name;
|
|
68996
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
68999
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
|
|
68997
69000
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
68998
69001
|
return void 0;
|
|
68999
69002
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -70042,7 +70045,9 @@ ${lanes.join("\n")}
|
|
|
70042
70045
|
elementTypes.push(undefinedOrMissingType);
|
|
70043
70046
|
elementFlags.push(2 /* Optional */);
|
|
70044
70047
|
} else {
|
|
70045
|
-
const
|
|
70048
|
+
const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
|
|
70049
|
+
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70050
|
+
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
70046
70051
|
elementTypes.push(addOptionality(
|
|
70047
70052
|
type,
|
|
70048
70053
|
/*isProperty*/
|
|
@@ -70050,7 +70055,7 @@ ${lanes.join("\n")}
|
|
|
70050
70055
|
hasOmittedExpression
|
|
70051
70056
|
));
|
|
70052
70057
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
70053
|
-
if (
|
|
70058
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
70054
70059
|
const inferenceContext = getInferenceContext(node);
|
|
70055
70060
|
Debug.assert(inferenceContext);
|
|
70056
70061
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -70191,11 +70196,13 @@ ${lanes.join("\n")}
|
|
|
70191
70196
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
70192
70197
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
70193
70198
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
70194
|
-
|
|
70199
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
70200
|
+
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70201
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
70195
70202
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
70196
70203
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
70197
70204
|
// we don't want to say "could not find 'a'".
|
|
70198
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
70205
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
|
|
70199
70206
|
);
|
|
70200
70207
|
if (isInJavascript) {
|
|
70201
70208
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -70239,7 +70246,7 @@ ${lanes.join("\n")}
|
|
|
70239
70246
|
prop.links.target = member;
|
|
70240
70247
|
member = prop;
|
|
70241
70248
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
70242
|
-
if (
|
|
70249
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
70243
70250
|
const inferenceContext = getInferenceContext(node);
|
|
70244
70251
|
Debug.assert(inferenceContext);
|
|
70245
70252
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -70412,7 +70419,9 @@ ${lanes.join("\n")}
|
|
|
70412
70419
|
for (const attributeDecl of attributes.properties) {
|
|
70413
70420
|
const member = attributeDecl.symbol;
|
|
70414
70421
|
if (isJsxAttribute(attributeDecl)) {
|
|
70415
|
-
const
|
|
70422
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
|
|
70423
|
+
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70424
|
+
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
70416
70425
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
70417
70426
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
70418
70427
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -70433,7 +70442,7 @@ ${lanes.join("\n")}
|
|
|
70433
70442
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
70434
70443
|
}
|
|
70435
70444
|
}
|
|
70436
|
-
if (
|
|
70445
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
70437
70446
|
const inferenceContext = getInferenceContext(attributes);
|
|
70438
70447
|
Debug.assert(inferenceContext);
|
|
70439
70448
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72051,7 +72060,7 @@ ${lanes.join("\n")}
|
|
|
72051
72060
|
}
|
|
72052
72061
|
for (let i = 0; i < argCount; i++) {
|
|
72053
72062
|
const arg = args[i];
|
|
72054
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
72063
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
72055
72064
|
const paramType = getTypeAtPosition(signature, i);
|
|
72056
72065
|
if (couldContainTypeVariables(paramType)) {
|
|
72057
72066
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -72664,12 +72673,12 @@ ${lanes.join("\n")}
|
|
|
72664
72673
|
const args = getEffectiveCallArguments(node);
|
|
72665
72674
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
72666
72675
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
72667
|
-
argCheckMode |= checkMode &
|
|
72676
|
+
argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
72668
72677
|
let candidatesForArgumentError;
|
|
72669
72678
|
let candidateForArgumentArityError;
|
|
72670
72679
|
let candidateForTypeArgumentError;
|
|
72671
72680
|
let result;
|
|
72672
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
72681
|
+
const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
72673
72682
|
if (candidates.length > 1) {
|
|
72674
72683
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
72675
72684
|
}
|
|
@@ -72888,7 +72897,7 @@ ${lanes.join("\n")}
|
|
|
72888
72897
|
continue;
|
|
72889
72898
|
}
|
|
72890
72899
|
if (argCheckMode) {
|
|
72891
|
-
argCheckMode = checkMode &
|
|
72900
|
+
argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
72892
72901
|
if (inferenceContext) {
|
|
72893
72902
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72894
72903
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75966,7 +75975,7 @@ ${lanes.join("\n")}
|
|
|
75966
75975
|
case 36 /* ExclamationEqualsToken */:
|
|
75967
75976
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
75968
75977
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
75969
|
-
if (!(checkMode && checkMode &
|
|
75978
|
+
if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
|
|
75970
75979
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
75971
75980
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
75972
75981
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -76625,7 +76634,7 @@ ${lanes.join("\n")}
|
|
|
76625
76634
|
}
|
|
76626
76635
|
}
|
|
76627
76636
|
const startInvocationCount = flowInvocationCount;
|
|
76628
|
-
const type = checkExpression(node,
|
|
76637
|
+
const type = checkExpression(node, 256 /* TypeOnly */);
|
|
76629
76638
|
if (flowInvocationCount !== startInvocationCount) {
|
|
76630
76639
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
76631
76640
|
cache[getNodeId(node)] = type;
|
|
@@ -79096,7 +79105,7 @@ ${lanes.join("\n")}
|
|
|
79096
79105
|
checkComputedPropertyName(node.propertyName);
|
|
79097
79106
|
}
|
|
79098
79107
|
const parent2 = node.parent.parent;
|
|
79099
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
79108
|
+
const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
79100
79109
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
79101
79110
|
const name = node.propertyName || node.name;
|
|
79102
79111
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -85832,10 +85841,11 @@ ${lanes.join("\n")}
|
|
|
85832
85841
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
85833
85842
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
85834
85843
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
85835
|
-
CheckMode3[CheckMode3["
|
|
85836
|
-
CheckMode3[CheckMode3["
|
|
85837
|
-
CheckMode3[CheckMode3["
|
|
85838
|
-
CheckMode3[CheckMode3["
|
|
85844
|
+
CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
|
|
85845
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
|
|
85846
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
|
|
85847
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
|
|
85848
|
+
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
85839
85849
|
return CheckMode3;
|
|
85840
85850
|
})(CheckMode || {});
|
|
85841
85851
|
SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -162092,13 +162102,29 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162092
162102
|
if (!signature || !candidates.length) {
|
|
162093
162103
|
return;
|
|
162094
162104
|
}
|
|
162095
|
-
|
|
162096
|
-
|
|
162105
|
+
let signatureParamPos = 0;
|
|
162106
|
+
for (const originalArg of args) {
|
|
162097
162107
|
const arg = skipParentheses(originalArg);
|
|
162098
162108
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162099
162109
|
continue;
|
|
162100
162110
|
}
|
|
162101
|
-
|
|
162111
|
+
let spreadArgs = 0;
|
|
162112
|
+
if (isSpreadElement(arg)) {
|
|
162113
|
+
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162114
|
+
if (checker.isTupleType(spreadType)) {
|
|
162115
|
+
const { elementFlags, fixedLength } = spreadType.target;
|
|
162116
|
+
if (fixedLength === 0) {
|
|
162117
|
+
continue;
|
|
162118
|
+
}
|
|
162119
|
+
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162120
|
+
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162121
|
+
if (requiredArgs > 0) {
|
|
162122
|
+
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162123
|
+
}
|
|
162124
|
+
}
|
|
162125
|
+
}
|
|
162126
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162127
|
+
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162102
162128
|
if (identifierNameInfo) {
|
|
162103
162129
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162104
162130
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.2";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230606`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -45382,9 +45382,9 @@ ${lanes.join("\n")}
|
|
|
45382
45382
|
candidatesOutArray,
|
|
45383
45383
|
/*argumentCount*/
|
|
45384
45384
|
void 0,
|
|
45385
|
-
|
|
45385
|
+
64 /* IsForStringLiteralArgumentCompletions */
|
|
45386
45386
|
)),
|
|
45387
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
45387
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
|
|
45388
45388
|
getExpandedParameters,
|
|
45389
45389
|
hasEffectiveRestParameter,
|
|
45390
45390
|
containsArgumentsReference,
|
|
@@ -53339,7 +53339,7 @@ ${lanes.join("\n")}
|
|
|
53339
53339
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
53340
53340
|
}
|
|
53341
53341
|
function getTypeForBindingElement(declaration) {
|
|
53342
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
53342
|
+
const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
53343
53343
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
53344
53344
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
53345
53345
|
}
|
|
@@ -60537,7 +60537,10 @@ ${lanes.join("\n")}
|
|
|
60537
60537
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
60538
60538
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
60539
60539
|
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
60540
|
-
|
|
60540
|
+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
60541
|
+
if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
60542
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
60543
|
+
}
|
|
60541
60544
|
}
|
|
60542
60545
|
target.instantiations.set(id, result);
|
|
60543
60546
|
}
|
|
@@ -68236,7 +68239,7 @@ ${lanes.join("\n")}
|
|
|
68236
68239
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
68237
68240
|
}
|
|
68238
68241
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
68239
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
68242
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
68240
68243
|
node,
|
|
68241
68244
|
/*contextFlags*/
|
|
68242
68245
|
void 0
|
|
@@ -68993,7 +68996,7 @@ ${lanes.join("\n")}
|
|
|
68993
68996
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
68994
68997
|
const parent2 = declaration.parent.parent;
|
|
68995
68998
|
const name = declaration.propertyName || declaration.name;
|
|
68996
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
68999
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
|
|
68997
69000
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
68998
69001
|
return void 0;
|
|
68999
69002
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -70042,7 +70045,9 @@ ${lanes.join("\n")}
|
|
|
70042
70045
|
elementTypes.push(undefinedOrMissingType);
|
|
70043
70046
|
elementFlags.push(2 /* Optional */);
|
|
70044
70047
|
} else {
|
|
70045
|
-
const
|
|
70048
|
+
const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
|
|
70049
|
+
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70050
|
+
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
70046
70051
|
elementTypes.push(addOptionality(
|
|
70047
70052
|
type,
|
|
70048
70053
|
/*isProperty*/
|
|
@@ -70050,7 +70055,7 @@ ${lanes.join("\n")}
|
|
|
70050
70055
|
hasOmittedExpression
|
|
70051
70056
|
));
|
|
70052
70057
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
70053
|
-
if (
|
|
70058
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
70054
70059
|
const inferenceContext = getInferenceContext(node);
|
|
70055
70060
|
Debug.assert(inferenceContext);
|
|
70056
70061
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -70191,11 +70196,13 @@ ${lanes.join("\n")}
|
|
|
70191
70196
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
70192
70197
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
70193
70198
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
70194
|
-
|
|
70199
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
70200
|
+
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70201
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
70195
70202
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
70196
70203
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
70197
70204
|
// we don't want to say "could not find 'a'".
|
|
70198
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
70205
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
|
|
70199
70206
|
);
|
|
70200
70207
|
if (isInJavascript) {
|
|
70201
70208
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -70239,7 +70246,7 @@ ${lanes.join("\n")}
|
|
|
70239
70246
|
prop.links.target = member;
|
|
70240
70247
|
member = prop;
|
|
70241
70248
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
70242
|
-
if (
|
|
70249
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
70243
70250
|
const inferenceContext = getInferenceContext(node);
|
|
70244
70251
|
Debug.assert(inferenceContext);
|
|
70245
70252
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -70412,7 +70419,9 @@ ${lanes.join("\n")}
|
|
|
70412
70419
|
for (const attributeDecl of attributes.properties) {
|
|
70413
70420
|
const member = attributeDecl.symbol;
|
|
70414
70421
|
if (isJsxAttribute(attributeDecl)) {
|
|
70415
|
-
const
|
|
70422
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
|
|
70423
|
+
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70424
|
+
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
70416
70425
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
70417
70426
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
70418
70427
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -70433,7 +70442,7 @@ ${lanes.join("\n")}
|
|
|
70433
70442
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
70434
70443
|
}
|
|
70435
70444
|
}
|
|
70436
|
-
if (
|
|
70445
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
70437
70446
|
const inferenceContext = getInferenceContext(attributes);
|
|
70438
70447
|
Debug.assert(inferenceContext);
|
|
70439
70448
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72051,7 +72060,7 @@ ${lanes.join("\n")}
|
|
|
72051
72060
|
}
|
|
72052
72061
|
for (let i = 0; i < argCount; i++) {
|
|
72053
72062
|
const arg = args[i];
|
|
72054
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
72063
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
72055
72064
|
const paramType = getTypeAtPosition(signature, i);
|
|
72056
72065
|
if (couldContainTypeVariables(paramType)) {
|
|
72057
72066
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -72664,12 +72673,12 @@ ${lanes.join("\n")}
|
|
|
72664
72673
|
const args = getEffectiveCallArguments(node);
|
|
72665
72674
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
72666
72675
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
72667
|
-
argCheckMode |= checkMode &
|
|
72676
|
+
argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
72668
72677
|
let candidatesForArgumentError;
|
|
72669
72678
|
let candidateForArgumentArityError;
|
|
72670
72679
|
let candidateForTypeArgumentError;
|
|
72671
72680
|
let result;
|
|
72672
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
72681
|
+
const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
72673
72682
|
if (candidates.length > 1) {
|
|
72674
72683
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
72675
72684
|
}
|
|
@@ -72888,7 +72897,7 @@ ${lanes.join("\n")}
|
|
|
72888
72897
|
continue;
|
|
72889
72898
|
}
|
|
72890
72899
|
if (argCheckMode) {
|
|
72891
|
-
argCheckMode = checkMode &
|
|
72900
|
+
argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
72892
72901
|
if (inferenceContext) {
|
|
72893
72902
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72894
72903
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75966,7 +75975,7 @@ ${lanes.join("\n")}
|
|
|
75966
75975
|
case 36 /* ExclamationEqualsToken */:
|
|
75967
75976
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
75968
75977
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
75969
|
-
if (!(checkMode && checkMode &
|
|
75978
|
+
if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
|
|
75970
75979
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
75971
75980
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
75972
75981
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -76625,7 +76634,7 @@ ${lanes.join("\n")}
|
|
|
76625
76634
|
}
|
|
76626
76635
|
}
|
|
76627
76636
|
const startInvocationCount = flowInvocationCount;
|
|
76628
|
-
const type = checkExpression(node,
|
|
76637
|
+
const type = checkExpression(node, 256 /* TypeOnly */);
|
|
76629
76638
|
if (flowInvocationCount !== startInvocationCount) {
|
|
76630
76639
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
76631
76640
|
cache[getNodeId(node)] = type;
|
|
@@ -79096,7 +79105,7 @@ ${lanes.join("\n")}
|
|
|
79096
79105
|
checkComputedPropertyName(node.propertyName);
|
|
79097
79106
|
}
|
|
79098
79107
|
const parent2 = node.parent.parent;
|
|
79099
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
79108
|
+
const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
79100
79109
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
79101
79110
|
const name = node.propertyName || node.name;
|
|
79102
79111
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -85832,10 +85841,11 @@ ${lanes.join("\n")}
|
|
|
85832
85841
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
85833
85842
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
85834
85843
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
85835
|
-
CheckMode3[CheckMode3["
|
|
85836
|
-
CheckMode3[CheckMode3["
|
|
85837
|
-
CheckMode3[CheckMode3["
|
|
85838
|
-
CheckMode3[CheckMode3["
|
|
85844
|
+
CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
|
|
85845
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
|
|
85846
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
|
|
85847
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
|
|
85848
|
+
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
85839
85849
|
return CheckMode3;
|
|
85840
85850
|
})(CheckMode || {});
|
|
85841
85851
|
SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -162107,13 +162117,29 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162107
162117
|
if (!signature || !candidates.length) {
|
|
162108
162118
|
return;
|
|
162109
162119
|
}
|
|
162110
|
-
|
|
162111
|
-
|
|
162120
|
+
let signatureParamPos = 0;
|
|
162121
|
+
for (const originalArg of args) {
|
|
162112
162122
|
const arg = skipParentheses(originalArg);
|
|
162113
162123
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162114
162124
|
continue;
|
|
162115
162125
|
}
|
|
162116
|
-
|
|
162126
|
+
let spreadArgs = 0;
|
|
162127
|
+
if (isSpreadElement(arg)) {
|
|
162128
|
+
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162129
|
+
if (checker.isTupleType(spreadType)) {
|
|
162130
|
+
const { elementFlags, fixedLength } = spreadType.target;
|
|
162131
|
+
if (fixedLength === 0) {
|
|
162132
|
+
continue;
|
|
162133
|
+
}
|
|
162134
|
+
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162135
|
+
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162136
|
+
if (requiredArgs > 0) {
|
|
162137
|
+
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162138
|
+
}
|
|
162139
|
+
}
|
|
162140
|
+
}
|
|
162141
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162142
|
+
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162117
162143
|
if (identifierNameInfo) {
|
|
162118
162144
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162119
162145
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
|
|
|
54
54
|
|
|
55
55
|
// src/compiler/corePublic.ts
|
|
56
56
|
var versionMajorMinor = "5.2";
|
|
57
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
57
|
+
var version = `${versionMajorMinor}.0-dev.20230606`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -28918,10 +28918,11 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
28918
28918
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
28919
28919
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
28920
28920
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
28921
|
-
CheckMode3[CheckMode3["
|
|
28922
|
-
CheckMode3[CheckMode3["
|
|
28923
|
-
CheckMode3[CheckMode3["
|
|
28924
|
-
CheckMode3[CheckMode3["
|
|
28921
|
+
CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
|
|
28922
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
|
|
28923
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
|
|
28924
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
|
|
28925
|
+
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
28925
28926
|
return CheckMode3;
|
|
28926
28927
|
})(CheckMode || {});
|
|
28927
28928
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.2.0-dev.
|
|
5
|
+
"version": "5.2.0-dev.20230606",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"node": "20.1.0",
|
|
115
115
|
"npm": "8.19.4"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "324e61e4519d010f2dd929b88fe3e9eedcfc5d44"
|
|
118
118
|
}
|