typescript 5.2.0-dev.20230524 → 5.2.0-dev.20230527
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 +50 -38
- package/lib/tsserver.js +132 -76
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +132 -76
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +132 -76
- package/lib/typingsInstaller.js +2 -1
- 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.20230527`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -42656,6 +42656,7 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
42656
42656
|
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
42657
42657
|
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
42658
42658
|
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
42659
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
42659
42660
|
return CheckMode3;
|
|
42660
42661
|
})(CheckMode || {});
|
|
42661
42662
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -47902,32 +47903,34 @@ function createTypeChecker(host) {
|
|
|
47902
47903
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 172 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
47903
47904
|
typeElements.push(preserveCommentsOn(methodDeclaration));
|
|
47904
47905
|
}
|
|
47906
|
+
if (signatures.length || !optionalToken) {
|
|
47907
|
+
return;
|
|
47908
|
+
}
|
|
47909
|
+
}
|
|
47910
|
+
let propertyTypeNode;
|
|
47911
|
+
if (shouldUsePlaceholderForProperty(propertySymbol, context)) {
|
|
47912
|
+
propertyTypeNode = createElidedInformationPlaceholder(context);
|
|
47905
47913
|
} else {
|
|
47906
|
-
|
|
47907
|
-
|
|
47908
|
-
|
|
47909
|
-
} else {
|
|
47910
|
-
if (propertyIsReverseMapped) {
|
|
47911
|
-
context.reverseMappedStack || (context.reverseMappedStack = []);
|
|
47912
|
-
context.reverseMappedStack.push(propertySymbol);
|
|
47913
|
-
}
|
|
47914
|
-
propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
47915
|
-
if (propertyIsReverseMapped) {
|
|
47916
|
-
context.reverseMappedStack.pop();
|
|
47917
|
-
}
|
|
47914
|
+
if (propertyIsReverseMapped) {
|
|
47915
|
+
context.reverseMappedStack || (context.reverseMappedStack = []);
|
|
47916
|
+
context.reverseMappedStack.push(propertySymbol);
|
|
47918
47917
|
}
|
|
47919
|
-
|
|
47920
|
-
if (
|
|
47921
|
-
context.
|
|
47918
|
+
propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
47919
|
+
if (propertyIsReverseMapped) {
|
|
47920
|
+
context.reverseMappedStack.pop();
|
|
47922
47921
|
}
|
|
47923
|
-
const propertySignature = factory.createPropertySignature(
|
|
47924
|
-
modifiers,
|
|
47925
|
-
propertyName,
|
|
47926
|
-
optionalToken,
|
|
47927
|
-
propertyTypeNode
|
|
47928
|
-
);
|
|
47929
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
47930
47922
|
}
|
|
47923
|
+
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
47924
|
+
if (modifiers) {
|
|
47925
|
+
context.approximateLength += 9;
|
|
47926
|
+
}
|
|
47927
|
+
const propertySignature = factory.createPropertySignature(
|
|
47928
|
+
modifiers,
|
|
47929
|
+
propertyName,
|
|
47930
|
+
optionalToken,
|
|
47931
|
+
propertyTypeNode
|
|
47932
|
+
);
|
|
47933
|
+
typeElements.push(preserveCommentsOn(propertySignature));
|
|
47931
47934
|
function preserveCommentsOn(node) {
|
|
47932
47935
|
var _a2;
|
|
47933
47936
|
if (some(propertySymbol.declarations, (d) => d.kind === 354 /* JSDocPropertyTag */)) {
|
|
@@ -57280,9 +57283,9 @@ function createTypeChecker(host) {
|
|
|
57280
57283
|
);
|
|
57281
57284
|
if (freshMapper) {
|
|
57282
57285
|
const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
|
|
57283
|
-
for (
|
|
57284
|
-
if (root.inferTypeParameters
|
|
57285
|
-
|
|
57286
|
+
for (let i = 0; i < freshParams.length; i++) {
|
|
57287
|
+
if (freshParams[i] !== root.inferTypeParameters[i]) {
|
|
57288
|
+
freshParams[i].mapper = freshCombinedMapper;
|
|
57286
57289
|
}
|
|
57287
57290
|
}
|
|
57288
57291
|
}
|
|
@@ -58185,6 +58188,9 @@ function createTypeChecker(host) {
|
|
|
58185
58188
|
const elementFlags = tupleType.target.elementFlags;
|
|
58186
58189
|
const elementTypes = map(getElementTypes(tupleType), (t, i) => {
|
|
58187
58190
|
const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
|
|
58191
|
+
if (singleton === typeVariable) {
|
|
58192
|
+
return mappedType;
|
|
58193
|
+
}
|
|
58188
58194
|
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
58189
58195
|
});
|
|
58190
58196
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
|
|
@@ -58522,6 +58528,10 @@ function createTypeChecker(host) {
|
|
|
58522
58528
|
return true;
|
|
58523
58529
|
}
|
|
58524
58530
|
switch (node.kind) {
|
|
58531
|
+
case 233 /* AsExpression */:
|
|
58532
|
+
if (!isConstAssertion(node)) {
|
|
58533
|
+
break;
|
|
58534
|
+
}
|
|
58525
58535
|
case 293 /* JsxExpression */:
|
|
58526
58536
|
case 216 /* ParenthesizedExpression */:
|
|
58527
58537
|
return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
|
|
@@ -64800,7 +64810,7 @@ function createTypeChecker(host) {
|
|
|
64800
64810
|
target.antecedents = saveAntecedents;
|
|
64801
64811
|
} else if (flags & 2 /* Start */) {
|
|
64802
64812
|
const container = flow.node;
|
|
64803
|
-
if (container && container !== flowContainer && reference.kind !== 210 /* PropertyAccessExpression */ && reference.kind !== 211 /* ElementAccessExpression */ && reference.kind
|
|
64813
|
+
if (container && container !== flowContainer && reference.kind !== 210 /* PropertyAccessExpression */ && reference.kind !== 211 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 218 /* ArrowFunction */)) {
|
|
64804
64814
|
flow = container.flowNode;
|
|
64805
64815
|
continue;
|
|
64806
64816
|
}
|
|
@@ -73287,7 +73297,7 @@ function createTypeChecker(host) {
|
|
|
73287
73297
|
Debug.assertIsDefined(leftType);
|
|
73288
73298
|
const rightType = getLastResult(state);
|
|
73289
73299
|
Debug.assertIsDefined(rightType);
|
|
73290
|
-
result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node);
|
|
73300
|
+
result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, state.checkMode, node);
|
|
73291
73301
|
}
|
|
73292
73302
|
state.skip = false;
|
|
73293
73303
|
setLeftType(
|
|
@@ -73349,9 +73359,9 @@ function createTypeChecker(host) {
|
|
|
73349
73359
|
leftType = checkExpression(left, checkMode);
|
|
73350
73360
|
}
|
|
73351
73361
|
const rightType = checkExpression(right, checkMode);
|
|
73352
|
-
return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
|
|
73362
|
+
return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode);
|
|
73353
73363
|
}
|
|
73354
|
-
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
|
|
73364
|
+
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode) {
|
|
73355
73365
|
const operator = operatorToken.kind;
|
|
73356
73366
|
switch (operator) {
|
|
73357
73367
|
case 42 /* AsteriskToken */:
|
|
@@ -73508,12 +73518,14 @@ function createTypeChecker(host) {
|
|
|
73508
73518
|
case 36 /* ExclamationEqualsToken */:
|
|
73509
73519
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
73510
73520
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
73511
|
-
if (
|
|
73512
|
-
|
|
73513
|
-
|
|
73521
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
73522
|
+
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
73523
|
+
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
73524
|
+
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
73525
|
+
}
|
|
73526
|
+
checkNaNEquality(errorNode, operator, left, right);
|
|
73527
|
+
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
73514
73528
|
}
|
|
73515
|
-
checkNaNEquality(errorNode, operator, left, right);
|
|
73516
|
-
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
73517
73529
|
return booleanType;
|
|
73518
73530
|
case 104 /* InstanceOfKeyword */:
|
|
73519
73531
|
return checkInstanceOfExpression(left, right, leftType, rightType);
|
|
@@ -73824,7 +73836,7 @@ function createTypeChecker(host) {
|
|
|
73824
73836
|
}
|
|
73825
73837
|
}
|
|
73826
73838
|
function checkConditionalExpression(node, checkMode) {
|
|
73827
|
-
const type = checkTruthinessExpression(node.condition);
|
|
73839
|
+
const type = checkTruthinessExpression(node.condition, checkMode);
|
|
73828
73840
|
checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
|
|
73829
73841
|
const type1 = checkExpression(node.whenTrue, checkMode);
|
|
73830
73842
|
const type2 = checkExpression(node.whenFalse, checkMode);
|
|
@@ -74165,7 +74177,7 @@ function createTypeChecker(host) {
|
|
|
74165
74177
|
}
|
|
74166
74178
|
}
|
|
74167
74179
|
const startInvocationCount = flowInvocationCount;
|
|
74168
|
-
const type = checkExpression(node);
|
|
74180
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
74169
74181
|
if (flowInvocationCount !== startInvocationCount) {
|
|
74170
74182
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
74171
74183
|
cache[getNodeId(node)] = type;
|
|
@@ -74241,7 +74253,7 @@ function createTypeChecker(host) {
|
|
|
74241
74253
|
if (getIsolatedModules(compilerOptions)) {
|
|
74242
74254
|
Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
74243
74255
|
const constEnumDeclaration = type.symbol.valueDeclaration;
|
|
74244
|
-
if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
|
|
74256
|
+
if (constEnumDeclaration.flags & 16777216 /* Ambient */ && !isValidTypeOnlyAliasUseSite(node)) {
|
|
74245
74257
|
error(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
|
|
74246
74258
|
}
|
|
74247
74259
|
}
|