typescript 5.1.0-dev.20230316 → 5.1.0-dev.20230318
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 +72 -25
- package/lib/tsserver.js +76 -25
- package/lib/tsserverlibrary.js +76 -25
- package/lib/typescript.js +74 -25
- package/lib/typingsInstaller.js +4 -2
- package/package.json +3 -3
package/lib/tsc.js
CHANGED
|
@@ -23,7 +23,7 @@ var __export = (target, all) => {
|
|
|
23
23
|
|
|
24
24
|
// src/compiler/corePublic.ts
|
|
25
25
|
var versionMajorMinor = "5.1";
|
|
26
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
26
|
+
var version = `${versionMajorMinor}.0-dev.20230318`;
|
|
27
27
|
|
|
28
28
|
// src/compiler/core.ts
|
|
29
29
|
var emptyArray = [];
|
|
@@ -3721,7 +3721,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3721
3721
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
3722
3722
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
3723
3723
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
3724
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
3724
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
3725
3725
|
return TypeFlags2;
|
|
3726
3726
|
})(TypeFlags || {});
|
|
3727
3727
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -6656,6 +6656,8 @@ var Diagnostics = {
|
|
|
6656
6656
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
6657
6657
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
6658
6658
|
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
6659
|
+
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
6660
|
+
The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
|
|
6659
6661
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
6660
6662
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
6661
6663
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -56000,7 +56002,7 @@ function createTypeChecker(host) {
|
|
|
56000
56002
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
56001
56003
|
}
|
|
56002
56004
|
}
|
|
56003
|
-
const objectFlags = (includes &
|
|
56005
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
56004
56006
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
56005
56007
|
}
|
|
56006
56008
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -56125,7 +56127,7 @@ function createTypeChecker(host) {
|
|
|
56125
56127
|
function eachUnionContains(unionTypes2, type) {
|
|
56126
56128
|
for (const u of unionTypes2) {
|
|
56127
56129
|
if (!containsType(u.types, type)) {
|
|
56128
|
-
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
56130
|
+
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
56129
56131
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
56130
56132
|
return false;
|
|
56131
56133
|
}
|
|
@@ -56152,9 +56154,6 @@ function createTypeChecker(host) {
|
|
|
56152
56154
|
}
|
|
56153
56155
|
return false;
|
|
56154
56156
|
}
|
|
56155
|
-
function eachIsUnionContaining(types, flag) {
|
|
56156
|
-
return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
|
|
56157
|
-
}
|
|
56158
56157
|
function removeFromEach(types, flag) {
|
|
56159
56158
|
for (let i = 0; i < types.length; i++) {
|
|
56160
56159
|
types[i] = filterType(types[i], (t) => !(t.flags & flag));
|
|
@@ -56243,11 +56242,11 @@ function createTypeChecker(host) {
|
|
|
56243
56242
|
if (includes & 1048576 /* Union */) {
|
|
56244
56243
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
56245
56244
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
56246
|
-
} else if (
|
|
56245
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
56247
56246
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
56248
56247
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
56249
56248
|
result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
56250
|
-
} else if (
|
|
56249
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
56251
56250
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
56252
56251
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
56253
56252
|
} else {
|
|
@@ -58635,8 +58634,20 @@ function createTypeChecker(host) {
|
|
|
58635
58634
|
return result;
|
|
58636
58635
|
}
|
|
58637
58636
|
const moreThanOneRealChildren = length(validChildren) > 1;
|
|
58638
|
-
|
|
58639
|
-
|
|
58637
|
+
let arrayLikeTargetParts;
|
|
58638
|
+
let nonArrayLikeTargetParts;
|
|
58639
|
+
const iterableType = getGlobalIterableType(
|
|
58640
|
+
/*reportErrors*/
|
|
58641
|
+
false
|
|
58642
|
+
);
|
|
58643
|
+
if (iterableType !== emptyGenericType) {
|
|
58644
|
+
const anyIterable = createIterableType(anyType);
|
|
58645
|
+
arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
|
|
58646
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
|
|
58647
|
+
} else {
|
|
58648
|
+
arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
|
|
58649
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
|
|
58650
|
+
}
|
|
58640
58651
|
if (moreThanOneRealChildren) {
|
|
58641
58652
|
if (arrayLikeTargetParts !== neverType) {
|
|
58642
58653
|
const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
|
|
@@ -59760,6 +59771,11 @@ function createTypeChecker(host) {
|
|
|
59760
59771
|
if (containsType(targetTypes, source2)) {
|
|
59761
59772
|
return -1 /* True */;
|
|
59762
59773
|
}
|
|
59774
|
+
if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
|
|
59775
|
+
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
59776
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
59777
|
+
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
59778
|
+
}
|
|
59763
59779
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
59764
59780
|
if (match) {
|
|
59765
59781
|
const related = isRelatedTo(
|
|
@@ -61916,13 +61932,6 @@ function createTypeChecker(host) {
|
|
|
61916
61932
|
function isArrayOrTupleLikeType(type) {
|
|
61917
61933
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
61918
61934
|
}
|
|
61919
|
-
function isAssignableToAvailableAnyIterable(type) {
|
|
61920
|
-
const anyIterable = getGlobalIterableType(
|
|
61921
|
-
/*reportErrors*/
|
|
61922
|
-
false
|
|
61923
|
-
) !== emptyGenericType && createIterableType(anyType);
|
|
61924
|
-
return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
|
|
61925
|
-
}
|
|
61926
61935
|
function getTupleElementType(type, index) {
|
|
61927
61936
|
const propType = getTypeOfPropertyOfType(type, "" + index);
|
|
61928
61937
|
if (propType) {
|
|
@@ -66520,7 +66529,7 @@ function createTypeChecker(host) {
|
|
|
66520
66529
|
return void 0;
|
|
66521
66530
|
}
|
|
66522
66531
|
}
|
|
66523
|
-
return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
66532
|
+
return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
66524
66533
|
}
|
|
66525
66534
|
case 1 /* ExportsProperty */:
|
|
66526
66535
|
case 6 /* Prototype */:
|
|
@@ -66676,7 +66685,7 @@ function createTypeChecker(host) {
|
|
|
66676
66685
|
return void 0;
|
|
66677
66686
|
}
|
|
66678
66687
|
function getContextualTypeForElementExpression(arrayContextualType, index) {
|
|
66679
|
-
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(
|
|
66688
|
+
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
|
|
66680
66689
|
arrayContextualType,
|
|
66681
66690
|
(t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
|
|
66682
66691
|
t,
|
|
@@ -67418,7 +67427,7 @@ function createTypeChecker(host) {
|
|
|
67418
67427
|
const inConstContext = isConstContext(node);
|
|
67419
67428
|
const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
|
|
67420
67429
|
const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
|
|
67421
|
-
const enumTag = getJSDocEnumTag(node);
|
|
67430
|
+
const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
|
|
67422
67431
|
const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
|
|
67423
67432
|
let objectFlags = freshObjectLiteralFlag;
|
|
67424
67433
|
let patternWithComputedProperties = false;
|
|
@@ -71124,6 +71133,12 @@ function createTypeChecker(host) {
|
|
|
71124
71133
|
function checkExpressionWithTypeArguments(node) {
|
|
71125
71134
|
checkGrammarExpressionWithTypeArguments(node);
|
|
71126
71135
|
forEach(node.typeArguments, checkSourceElement);
|
|
71136
|
+
if (node.kind === 231 /* ExpressionWithTypeArguments */) {
|
|
71137
|
+
const parent = walkUpParenthesizedExpressions(node.parent);
|
|
71138
|
+
if (parent.kind === 224 /* BinaryExpression */ && parent.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent.right)) {
|
|
71139
|
+
error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
|
|
71140
|
+
}
|
|
71141
|
+
}
|
|
71127
71142
|
const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
|
|
71128
71143
|
return getInstantiationExpressionType(exprType, node);
|
|
71129
71144
|
}
|
|
@@ -72081,7 +72096,7 @@ function createTypeChecker(host) {
|
|
|
72081
72096
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
72082
72097
|
const functionFlags = getFunctionFlags(func);
|
|
72083
72098
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
72084
|
-
if (type && maybeTypeOfKind(type,
|
|
72099
|
+
if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
|
|
72085
72100
|
return;
|
|
72086
72101
|
}
|
|
72087
72102
|
if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -72092,8 +72107,12 @@ function createTypeChecker(host) {
|
|
|
72092
72107
|
if (type && type.flags & 131072 /* Never */) {
|
|
72093
72108
|
error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
72094
72109
|
} else if (type && !hasExplicitReturn) {
|
|
72095
|
-
|
|
72096
|
-
|
|
72110
|
+
if (strictNullChecks) {
|
|
72111
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
|
|
72112
|
+
} else {
|
|
72113
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
72114
|
+
}
|
|
72115
|
+
} else if (type && strictNullChecks) {
|
|
72097
72116
|
error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
72098
72117
|
} else if (compilerOptions.noImplicitReturns) {
|
|
72099
72118
|
if (!type) {
|
|
@@ -72175,6 +72194,11 @@ function createTypeChecker(host) {
|
|
|
72175
72194
|
} else {
|
|
72176
72195
|
assignNonContextualParameterTypes(signature);
|
|
72177
72196
|
}
|
|
72197
|
+
} else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
|
|
72198
|
+
const inferenceContext = getInferenceContext(node);
|
|
72199
|
+
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
72200
|
+
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
72201
|
+
}
|
|
72178
72202
|
}
|
|
72179
72203
|
if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
|
|
72180
72204
|
const returnType = getReturnTypeFromBody(node, checkMode);
|
|
@@ -79780,12 +79804,35 @@ function createTypeChecker(host) {
|
|
|
79780
79804
|
}
|
|
79781
79805
|
return void 0;
|
|
79782
79806
|
}
|
|
79807
|
+
function isThisPropertyAndThisTyped(node) {
|
|
79808
|
+
if (node.expression.kind === 109 /* ThisKeyword */) {
|
|
79809
|
+
const container = getThisContainer(
|
|
79810
|
+
node,
|
|
79811
|
+
/*includeArrowFunctions*/
|
|
79812
|
+
false,
|
|
79813
|
+
/*includeClassComputedPropertyName*/
|
|
79814
|
+
false
|
|
79815
|
+
);
|
|
79816
|
+
if (isFunctionLike(container)) {
|
|
79817
|
+
const containingLiteral = getContainingObjectLiteral(container);
|
|
79818
|
+
if (containingLiteral) {
|
|
79819
|
+
const contextualType = getApparentTypeOfContextualType(
|
|
79820
|
+
containingLiteral,
|
|
79821
|
+
/*contextFlags*/
|
|
79822
|
+
void 0
|
|
79823
|
+
);
|
|
79824
|
+
const type = contextualType && getThisTypeFromContextualType(contextualType);
|
|
79825
|
+
return type && !isTypeAny(type);
|
|
79826
|
+
}
|
|
79827
|
+
}
|
|
79828
|
+
}
|
|
79829
|
+
}
|
|
79783
79830
|
function getSymbolOfNameOrPropertyAccessExpression(name) {
|
|
79784
79831
|
if (isDeclarationName(name)) {
|
|
79785
79832
|
return getSymbolOfNode(name.parent);
|
|
79786
79833
|
}
|
|
79787
79834
|
if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
|
|
79788
|
-
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
|
|
79835
|
+
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
|
|
79789
79836
|
const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
|
|
79790
79837
|
if (specialPropertyAssignmentSymbol) {
|
|
79791
79838
|
return specialPropertyAssignmentSymbol;
|
package/lib/tsserver.js
CHANGED
|
@@ -2285,7 +2285,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2285
2285
|
|
|
2286
2286
|
// src/compiler/corePublic.ts
|
|
2287
2287
|
var versionMajorMinor = "5.1";
|
|
2288
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2288
|
+
var version = `${versionMajorMinor}.0-dev.20230318`;
|
|
2289
2289
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2290
2290
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2291
2291
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6642,7 +6642,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6642
6642
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
6643
6643
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
6644
6644
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
6645
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
6645
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
6646
6646
|
return TypeFlags2;
|
|
6647
6647
|
})(TypeFlags || {});
|
|
6648
6648
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -10118,6 +10118,8 @@ var Diagnostics = {
|
|
|
10118
10118
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
10119
10119
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
10120
10120
|
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
10121
|
+
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
10122
|
+
The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
|
|
10121
10123
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
10122
10124
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
10123
10125
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -60597,7 +60599,7 @@ function createTypeChecker(host) {
|
|
|
60597
60599
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
60598
60600
|
}
|
|
60599
60601
|
}
|
|
60600
|
-
const objectFlags = (includes &
|
|
60602
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
60601
60603
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60602
60604
|
}
|
|
60603
60605
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -60722,7 +60724,7 @@ function createTypeChecker(host) {
|
|
|
60722
60724
|
function eachUnionContains(unionTypes2, type) {
|
|
60723
60725
|
for (const u of unionTypes2) {
|
|
60724
60726
|
if (!containsType(u.types, type)) {
|
|
60725
|
-
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
60727
|
+
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
60726
60728
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
60727
60729
|
return false;
|
|
60728
60730
|
}
|
|
@@ -60749,9 +60751,6 @@ function createTypeChecker(host) {
|
|
|
60749
60751
|
}
|
|
60750
60752
|
return false;
|
|
60751
60753
|
}
|
|
60752
|
-
function eachIsUnionContaining(types, flag) {
|
|
60753
|
-
return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
|
|
60754
|
-
}
|
|
60755
60754
|
function removeFromEach(types, flag) {
|
|
60756
60755
|
for (let i = 0; i < types.length; i++) {
|
|
60757
60756
|
types[i] = filterType(types[i], (t) => !(t.flags & flag));
|
|
@@ -60840,11 +60839,11 @@ function createTypeChecker(host) {
|
|
|
60840
60839
|
if (includes & 1048576 /* Union */) {
|
|
60841
60840
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
60842
60841
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
60843
|
-
} else if (
|
|
60842
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
60844
60843
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
60845
60844
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
60846
60845
|
result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60847
|
-
} else if (
|
|
60846
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
60848
60847
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
60849
60848
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60850
60849
|
} else {
|
|
@@ -63232,8 +63231,20 @@ function createTypeChecker(host) {
|
|
|
63232
63231
|
return result;
|
|
63233
63232
|
}
|
|
63234
63233
|
const moreThanOneRealChildren = length(validChildren) > 1;
|
|
63235
|
-
|
|
63236
|
-
|
|
63234
|
+
let arrayLikeTargetParts;
|
|
63235
|
+
let nonArrayLikeTargetParts;
|
|
63236
|
+
const iterableType = getGlobalIterableType(
|
|
63237
|
+
/*reportErrors*/
|
|
63238
|
+
false
|
|
63239
|
+
);
|
|
63240
|
+
if (iterableType !== emptyGenericType) {
|
|
63241
|
+
const anyIterable = createIterableType(anyType);
|
|
63242
|
+
arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
|
|
63243
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
|
|
63244
|
+
} else {
|
|
63245
|
+
arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
|
|
63246
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
|
|
63247
|
+
}
|
|
63237
63248
|
if (moreThanOneRealChildren) {
|
|
63238
63249
|
if (arrayLikeTargetParts !== neverType) {
|
|
63239
63250
|
const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
|
|
@@ -64357,6 +64368,11 @@ function createTypeChecker(host) {
|
|
|
64357
64368
|
if (containsType(targetTypes, source2)) {
|
|
64358
64369
|
return -1 /* True */;
|
|
64359
64370
|
}
|
|
64371
|
+
if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
|
|
64372
|
+
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
64373
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
64374
|
+
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
64375
|
+
}
|
|
64360
64376
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
64361
64377
|
if (match) {
|
|
64362
64378
|
const related = isRelatedTo(
|
|
@@ -66513,13 +66529,6 @@ function createTypeChecker(host) {
|
|
|
66513
66529
|
function isArrayOrTupleLikeType(type) {
|
|
66514
66530
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
66515
66531
|
}
|
|
66516
|
-
function isAssignableToAvailableAnyIterable(type) {
|
|
66517
|
-
const anyIterable = getGlobalIterableType(
|
|
66518
|
-
/*reportErrors*/
|
|
66519
|
-
false
|
|
66520
|
-
) !== emptyGenericType && createIterableType(anyType);
|
|
66521
|
-
return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
|
|
66522
|
-
}
|
|
66523
66532
|
function getTupleElementType(type, index) {
|
|
66524
66533
|
const propType = getTypeOfPropertyOfType(type, "" + index);
|
|
66525
66534
|
if (propType) {
|
|
@@ -71117,7 +71126,7 @@ function createTypeChecker(host) {
|
|
|
71117
71126
|
return void 0;
|
|
71118
71127
|
}
|
|
71119
71128
|
}
|
|
71120
|
-
return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
71129
|
+
return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
71121
71130
|
}
|
|
71122
71131
|
case 1 /* ExportsProperty */:
|
|
71123
71132
|
case 6 /* Prototype */:
|
|
@@ -71273,7 +71282,7 @@ function createTypeChecker(host) {
|
|
|
71273
71282
|
return void 0;
|
|
71274
71283
|
}
|
|
71275
71284
|
function getContextualTypeForElementExpression(arrayContextualType, index) {
|
|
71276
|
-
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(
|
|
71285
|
+
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
|
|
71277
71286
|
arrayContextualType,
|
|
71278
71287
|
(t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
|
|
71279
71288
|
t,
|
|
@@ -72015,7 +72024,7 @@ function createTypeChecker(host) {
|
|
|
72015
72024
|
const inConstContext = isConstContext(node);
|
|
72016
72025
|
const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
|
|
72017
72026
|
const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
|
|
72018
|
-
const enumTag = getJSDocEnumTag(node);
|
|
72027
|
+
const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
|
|
72019
72028
|
const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
|
|
72020
72029
|
let objectFlags = freshObjectLiteralFlag;
|
|
72021
72030
|
let patternWithComputedProperties = false;
|
|
@@ -75721,6 +75730,12 @@ function createTypeChecker(host) {
|
|
|
75721
75730
|
function checkExpressionWithTypeArguments(node) {
|
|
75722
75731
|
checkGrammarExpressionWithTypeArguments(node);
|
|
75723
75732
|
forEach(node.typeArguments, checkSourceElement);
|
|
75733
|
+
if (node.kind === 231 /* ExpressionWithTypeArguments */) {
|
|
75734
|
+
const parent2 = walkUpParenthesizedExpressions(node.parent);
|
|
75735
|
+
if (parent2.kind === 224 /* BinaryExpression */ && parent2.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
|
|
75736
|
+
error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
|
|
75737
|
+
}
|
|
75738
|
+
}
|
|
75724
75739
|
const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
|
|
75725
75740
|
return getInstantiationExpressionType(exprType, node);
|
|
75726
75741
|
}
|
|
@@ -76678,7 +76693,7 @@ function createTypeChecker(host) {
|
|
|
76678
76693
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
76679
76694
|
const functionFlags = getFunctionFlags(func);
|
|
76680
76695
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
76681
|
-
if (type && maybeTypeOfKind(type,
|
|
76696
|
+
if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
|
|
76682
76697
|
return;
|
|
76683
76698
|
}
|
|
76684
76699
|
if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -76689,8 +76704,12 @@ function createTypeChecker(host) {
|
|
|
76689
76704
|
if (type && type.flags & 131072 /* Never */) {
|
|
76690
76705
|
error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
76691
76706
|
} else if (type && !hasExplicitReturn) {
|
|
76692
|
-
|
|
76693
|
-
|
|
76707
|
+
if (strictNullChecks) {
|
|
76708
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
|
|
76709
|
+
} else {
|
|
76710
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
76711
|
+
}
|
|
76712
|
+
} else if (type && strictNullChecks) {
|
|
76694
76713
|
error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
76695
76714
|
} else if (compilerOptions.noImplicitReturns) {
|
|
76696
76715
|
if (!type) {
|
|
@@ -76772,6 +76791,11 @@ function createTypeChecker(host) {
|
|
|
76772
76791
|
} else {
|
|
76773
76792
|
assignNonContextualParameterTypes(signature);
|
|
76774
76793
|
}
|
|
76794
|
+
} else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
|
|
76795
|
+
const inferenceContext = getInferenceContext(node);
|
|
76796
|
+
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
76797
|
+
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
76798
|
+
}
|
|
76775
76799
|
}
|
|
76776
76800
|
if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
|
|
76777
76801
|
const returnType = getReturnTypeFromBody(node, checkMode);
|
|
@@ -84377,12 +84401,35 @@ function createTypeChecker(host) {
|
|
|
84377
84401
|
}
|
|
84378
84402
|
return void 0;
|
|
84379
84403
|
}
|
|
84404
|
+
function isThisPropertyAndThisTyped(node) {
|
|
84405
|
+
if (node.expression.kind === 109 /* ThisKeyword */) {
|
|
84406
|
+
const container = getThisContainer(
|
|
84407
|
+
node,
|
|
84408
|
+
/*includeArrowFunctions*/
|
|
84409
|
+
false,
|
|
84410
|
+
/*includeClassComputedPropertyName*/
|
|
84411
|
+
false
|
|
84412
|
+
);
|
|
84413
|
+
if (isFunctionLike(container)) {
|
|
84414
|
+
const containingLiteral = getContainingObjectLiteral(container);
|
|
84415
|
+
if (containingLiteral) {
|
|
84416
|
+
const contextualType = getApparentTypeOfContextualType(
|
|
84417
|
+
containingLiteral,
|
|
84418
|
+
/*contextFlags*/
|
|
84419
|
+
void 0
|
|
84420
|
+
);
|
|
84421
|
+
const type = contextualType && getThisTypeFromContextualType(contextualType);
|
|
84422
|
+
return type && !isTypeAny(type);
|
|
84423
|
+
}
|
|
84424
|
+
}
|
|
84425
|
+
}
|
|
84426
|
+
}
|
|
84380
84427
|
function getSymbolOfNameOrPropertyAccessExpression(name) {
|
|
84381
84428
|
if (isDeclarationName(name)) {
|
|
84382
84429
|
return getSymbolOfNode(name.parent);
|
|
84383
84430
|
}
|
|
84384
84431
|
if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
|
|
84385
|
-
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
|
|
84432
|
+
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
|
|
84386
84433
|
const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
|
|
84387
84434
|
if (specialPropertyAssignmentSymbol) {
|
|
84388
84435
|
return specialPropertyAssignmentSymbol;
|
|
@@ -143613,6 +143660,7 @@ var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody
|
|
|
143613
143660
|
var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
143614
143661
|
var errorCodes26 = [
|
|
143615
143662
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
143663
|
+
Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
|
|
143616
143664
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
143617
143665
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
143618
143666
|
];
|
|
@@ -143764,6 +143812,7 @@ function getInfo6(checker, sourceFile, position, errorCode) {
|
|
|
143764
143812
|
const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
|
|
143765
143813
|
switch (errorCode) {
|
|
143766
143814
|
case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
|
|
143815
|
+
case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
|
|
143767
143816
|
if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
|
|
143768
143817
|
return void 0;
|
|
143769
143818
|
return getFixInfo(
|
|
@@ -170469,6 +170518,7 @@ __export(ts_server_exports2, {
|
|
|
170469
170518
|
emptyArray: () => emptyArray2,
|
|
170470
170519
|
findArgument: () => findArgument,
|
|
170471
170520
|
forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
|
|
170521
|
+
formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
|
|
170472
170522
|
formatMessage: () => formatMessage2,
|
|
170473
170523
|
getBaseConfigFileName: () => getBaseConfigFileName,
|
|
170474
170524
|
getLocationInNewDocument: () => getLocationInNewDocument,
|
|
@@ -181205,6 +181255,7 @@ __export(ts_server_exports3, {
|
|
|
181205
181255
|
emptyArray: () => emptyArray2,
|
|
181206
181256
|
findArgument: () => findArgument,
|
|
181207
181257
|
forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
|
|
181258
|
+
formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
|
|
181208
181259
|
formatMessage: () => formatMessage2,
|
|
181209
181260
|
getBaseConfigFileName: () => getBaseConfigFileName,
|
|
181210
181261
|
getLocationInNewDocument: () => getLocationInNewDocument,
|
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.1";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230318`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -4449,7 +4449,7 @@ ${lanes.join("\n")}
|
|
|
4449
4449
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
4450
4450
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
4451
4451
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
4452
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
4452
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
4453
4453
|
return TypeFlags2;
|
|
4454
4454
|
})(TypeFlags || {});
|
|
4455
4455
|
ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -7942,6 +7942,8 @@ ${lanes.join("\n")}
|
|
|
7942
7942
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
7943
7943
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
7944
7944
|
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
7945
|
+
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
7946
|
+
The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
|
|
7945
7947
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
7946
7948
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
7947
7949
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -58407,7 +58409,7 @@ ${lanes.join("\n")}
|
|
|
58407
58409
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
58408
58410
|
}
|
|
58409
58411
|
}
|
|
58410
|
-
const objectFlags = (includes &
|
|
58412
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
58411
58413
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
58412
58414
|
}
|
|
58413
58415
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -58532,7 +58534,7 @@ ${lanes.join("\n")}
|
|
|
58532
58534
|
function eachUnionContains(unionTypes2, type) {
|
|
58533
58535
|
for (const u of unionTypes2) {
|
|
58534
58536
|
if (!containsType(u.types, type)) {
|
|
58535
|
-
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
58537
|
+
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
58536
58538
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
58537
58539
|
return false;
|
|
58538
58540
|
}
|
|
@@ -58559,9 +58561,6 @@ ${lanes.join("\n")}
|
|
|
58559
58561
|
}
|
|
58560
58562
|
return false;
|
|
58561
58563
|
}
|
|
58562
|
-
function eachIsUnionContaining(types, flag) {
|
|
58563
|
-
return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
|
|
58564
|
-
}
|
|
58565
58564
|
function removeFromEach(types, flag) {
|
|
58566
58565
|
for (let i = 0; i < types.length; i++) {
|
|
58567
58566
|
types[i] = filterType(types[i], (t) => !(t.flags & flag));
|
|
@@ -58650,11 +58649,11 @@ ${lanes.join("\n")}
|
|
|
58650
58649
|
if (includes & 1048576 /* Union */) {
|
|
58651
58650
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
58652
58651
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
58653
|
-
} else if (
|
|
58652
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
58654
58653
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
58655
58654
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
58656
58655
|
result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58657
|
-
} else if (
|
|
58656
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
58658
58657
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
58659
58658
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58660
58659
|
} else {
|
|
@@ -61042,8 +61041,20 @@ ${lanes.join("\n")}
|
|
|
61042
61041
|
return result;
|
|
61043
61042
|
}
|
|
61044
61043
|
const moreThanOneRealChildren = length(validChildren) > 1;
|
|
61045
|
-
|
|
61046
|
-
|
|
61044
|
+
let arrayLikeTargetParts;
|
|
61045
|
+
let nonArrayLikeTargetParts;
|
|
61046
|
+
const iterableType = getGlobalIterableType(
|
|
61047
|
+
/*reportErrors*/
|
|
61048
|
+
false
|
|
61049
|
+
);
|
|
61050
|
+
if (iterableType !== emptyGenericType) {
|
|
61051
|
+
const anyIterable = createIterableType(anyType);
|
|
61052
|
+
arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
|
|
61053
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
|
|
61054
|
+
} else {
|
|
61055
|
+
arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
|
|
61056
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
|
|
61057
|
+
}
|
|
61047
61058
|
if (moreThanOneRealChildren) {
|
|
61048
61059
|
if (arrayLikeTargetParts !== neverType) {
|
|
61049
61060
|
const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
|
|
@@ -62167,6 +62178,11 @@ ${lanes.join("\n")}
|
|
|
62167
62178
|
if (containsType(targetTypes, source2)) {
|
|
62168
62179
|
return -1 /* True */;
|
|
62169
62180
|
}
|
|
62181
|
+
if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
|
|
62182
|
+
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
62183
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
62184
|
+
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
62185
|
+
}
|
|
62170
62186
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
62171
62187
|
if (match) {
|
|
62172
62188
|
const related = isRelatedTo(
|
|
@@ -64323,13 +64339,6 @@ ${lanes.join("\n")}
|
|
|
64323
64339
|
function isArrayOrTupleLikeType(type) {
|
|
64324
64340
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
64325
64341
|
}
|
|
64326
|
-
function isAssignableToAvailableAnyIterable(type) {
|
|
64327
|
-
const anyIterable = getGlobalIterableType(
|
|
64328
|
-
/*reportErrors*/
|
|
64329
|
-
false
|
|
64330
|
-
) !== emptyGenericType && createIterableType(anyType);
|
|
64331
|
-
return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
|
|
64332
|
-
}
|
|
64333
64342
|
function getTupleElementType(type, index) {
|
|
64334
64343
|
const propType = getTypeOfPropertyOfType(type, "" + index);
|
|
64335
64344
|
if (propType) {
|
|
@@ -68927,7 +68936,7 @@ ${lanes.join("\n")}
|
|
|
68927
68936
|
return void 0;
|
|
68928
68937
|
}
|
|
68929
68938
|
}
|
|
68930
|
-
return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
68939
|
+
return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
68931
68940
|
}
|
|
68932
68941
|
case 1 /* ExportsProperty */:
|
|
68933
68942
|
case 6 /* Prototype */:
|
|
@@ -69083,7 +69092,7 @@ ${lanes.join("\n")}
|
|
|
69083
69092
|
return void 0;
|
|
69084
69093
|
}
|
|
69085
69094
|
function getContextualTypeForElementExpression(arrayContextualType, index) {
|
|
69086
|
-
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(
|
|
69095
|
+
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
|
|
69087
69096
|
arrayContextualType,
|
|
69088
69097
|
(t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
|
|
69089
69098
|
t,
|
|
@@ -69825,7 +69834,7 @@ ${lanes.join("\n")}
|
|
|
69825
69834
|
const inConstContext = isConstContext(node);
|
|
69826
69835
|
const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
|
|
69827
69836
|
const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
|
|
69828
|
-
const enumTag = getJSDocEnumTag(node);
|
|
69837
|
+
const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
|
|
69829
69838
|
const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
|
|
69830
69839
|
let objectFlags = freshObjectLiteralFlag;
|
|
69831
69840
|
let patternWithComputedProperties = false;
|
|
@@ -73531,6 +73540,12 @@ ${lanes.join("\n")}
|
|
|
73531
73540
|
function checkExpressionWithTypeArguments(node) {
|
|
73532
73541
|
checkGrammarExpressionWithTypeArguments(node);
|
|
73533
73542
|
forEach(node.typeArguments, checkSourceElement);
|
|
73543
|
+
if (node.kind === 231 /* ExpressionWithTypeArguments */) {
|
|
73544
|
+
const parent2 = walkUpParenthesizedExpressions(node.parent);
|
|
73545
|
+
if (parent2.kind === 224 /* BinaryExpression */ && parent2.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
|
|
73546
|
+
error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
|
|
73547
|
+
}
|
|
73548
|
+
}
|
|
73534
73549
|
const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
|
|
73535
73550
|
return getInstantiationExpressionType(exprType, node);
|
|
73536
73551
|
}
|
|
@@ -74488,7 +74503,7 @@ ${lanes.join("\n")}
|
|
|
74488
74503
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
74489
74504
|
const functionFlags = getFunctionFlags(func);
|
|
74490
74505
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
74491
|
-
if (type && maybeTypeOfKind(type,
|
|
74506
|
+
if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
|
|
74492
74507
|
return;
|
|
74493
74508
|
}
|
|
74494
74509
|
if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -74499,8 +74514,12 @@ ${lanes.join("\n")}
|
|
|
74499
74514
|
if (type && type.flags & 131072 /* Never */) {
|
|
74500
74515
|
error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
74501
74516
|
} else if (type && !hasExplicitReturn) {
|
|
74502
|
-
|
|
74503
|
-
|
|
74517
|
+
if (strictNullChecks) {
|
|
74518
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
|
|
74519
|
+
} else {
|
|
74520
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
74521
|
+
}
|
|
74522
|
+
} else if (type && strictNullChecks) {
|
|
74504
74523
|
error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
74505
74524
|
} else if (compilerOptions.noImplicitReturns) {
|
|
74506
74525
|
if (!type) {
|
|
@@ -74582,6 +74601,11 @@ ${lanes.join("\n")}
|
|
|
74582
74601
|
} else {
|
|
74583
74602
|
assignNonContextualParameterTypes(signature);
|
|
74584
74603
|
}
|
|
74604
|
+
} else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
|
|
74605
|
+
const inferenceContext = getInferenceContext(node);
|
|
74606
|
+
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
74607
|
+
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
74608
|
+
}
|
|
74585
74609
|
}
|
|
74586
74610
|
if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
|
|
74587
74611
|
const returnType = getReturnTypeFromBody(node, checkMode);
|
|
@@ -82187,12 +82211,35 @@ ${lanes.join("\n")}
|
|
|
82187
82211
|
}
|
|
82188
82212
|
return void 0;
|
|
82189
82213
|
}
|
|
82214
|
+
function isThisPropertyAndThisTyped(node) {
|
|
82215
|
+
if (node.expression.kind === 109 /* ThisKeyword */) {
|
|
82216
|
+
const container = getThisContainer(
|
|
82217
|
+
node,
|
|
82218
|
+
/*includeArrowFunctions*/
|
|
82219
|
+
false,
|
|
82220
|
+
/*includeClassComputedPropertyName*/
|
|
82221
|
+
false
|
|
82222
|
+
);
|
|
82223
|
+
if (isFunctionLike(container)) {
|
|
82224
|
+
const containingLiteral = getContainingObjectLiteral(container);
|
|
82225
|
+
if (containingLiteral) {
|
|
82226
|
+
const contextualType = getApparentTypeOfContextualType(
|
|
82227
|
+
containingLiteral,
|
|
82228
|
+
/*contextFlags*/
|
|
82229
|
+
void 0
|
|
82230
|
+
);
|
|
82231
|
+
const type = contextualType && getThisTypeFromContextualType(contextualType);
|
|
82232
|
+
return type && !isTypeAny(type);
|
|
82233
|
+
}
|
|
82234
|
+
}
|
|
82235
|
+
}
|
|
82236
|
+
}
|
|
82190
82237
|
function getSymbolOfNameOrPropertyAccessExpression(name) {
|
|
82191
82238
|
if (isDeclarationName(name)) {
|
|
82192
82239
|
return getSymbolOfNode(name.parent);
|
|
82193
82240
|
}
|
|
82194
82241
|
if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
|
|
82195
|
-
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
|
|
82242
|
+
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
|
|
82196
82243
|
const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
|
|
82197
82244
|
if (specialPropertyAssignmentSymbol) {
|
|
82198
82245
|
return specialPropertyAssignmentSymbol;
|
|
@@ -142383,6 +142430,7 @@ ${lanes.join("\n")}
|
|
|
142383
142430
|
const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
|
|
142384
142431
|
switch (errorCode) {
|
|
142385
142432
|
case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
|
|
142433
|
+
case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
|
|
142386
142434
|
if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
|
|
142387
142435
|
return void 0;
|
|
142388
142436
|
return getFixInfo(
|
|
@@ -142490,6 +142538,7 @@ ${lanes.join("\n")}
|
|
|
142490
142538
|
fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
142491
142539
|
errorCodes26 = [
|
|
142492
142540
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
142541
|
+
Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
|
|
142493
142542
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
142494
142543
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
142495
142544
|
];
|
|
@@ -178581,6 +178630,7 @@ ${e.message}`;
|
|
|
178581
178630
|
emptyArray: () => emptyArray2,
|
|
178582
178631
|
findArgument: () => findArgument,
|
|
178583
178632
|
forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
|
|
178633
|
+
formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
|
|
178584
178634
|
formatMessage: () => formatMessage2,
|
|
178585
178635
|
getBaseConfigFileName: () => getBaseConfigFileName,
|
|
178586
178636
|
getLocationInNewDocument: () => getLocationInNewDocument,
|
|
@@ -180949,6 +180999,7 @@ ${e.message}`;
|
|
|
180949
180999
|
emptyArray: () => emptyArray2,
|
|
180950
181000
|
findArgument: () => findArgument,
|
|
180951
181001
|
forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
|
|
181002
|
+
formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
|
|
180952
181003
|
formatMessage: () => formatMessage2,
|
|
180953
181004
|
getBaseConfigFileName: () => getBaseConfigFileName,
|
|
180954
181005
|
getLocationInNewDocument: () => getLocationInNewDocument,
|
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.1";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230318`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -4449,7 +4449,7 @@ ${lanes.join("\n")}
|
|
|
4449
4449
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
4450
4450
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
4451
4451
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
4452
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
4452
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
4453
4453
|
return TypeFlags2;
|
|
4454
4454
|
})(TypeFlags || {});
|
|
4455
4455
|
ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -7942,6 +7942,8 @@ ${lanes.join("\n")}
|
|
|
7942
7942
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
7943
7943
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
7944
7944
|
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
7945
|
+
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
7946
|
+
The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
|
|
7945
7947
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
7946
7948
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
7947
7949
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -58407,7 +58409,7 @@ ${lanes.join("\n")}
|
|
|
58407
58409
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
58408
58410
|
}
|
|
58409
58411
|
}
|
|
58410
|
-
const objectFlags = (includes &
|
|
58412
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
58411
58413
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
58412
58414
|
}
|
|
58413
58415
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -58532,7 +58534,7 @@ ${lanes.join("\n")}
|
|
|
58532
58534
|
function eachUnionContains(unionTypes2, type) {
|
|
58533
58535
|
for (const u of unionTypes2) {
|
|
58534
58536
|
if (!containsType(u.types, type)) {
|
|
58535
|
-
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
58537
|
+
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
58536
58538
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
58537
58539
|
return false;
|
|
58538
58540
|
}
|
|
@@ -58559,9 +58561,6 @@ ${lanes.join("\n")}
|
|
|
58559
58561
|
}
|
|
58560
58562
|
return false;
|
|
58561
58563
|
}
|
|
58562
|
-
function eachIsUnionContaining(types, flag) {
|
|
58563
|
-
return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
|
|
58564
|
-
}
|
|
58565
58564
|
function removeFromEach(types, flag) {
|
|
58566
58565
|
for (let i = 0; i < types.length; i++) {
|
|
58567
58566
|
types[i] = filterType(types[i], (t) => !(t.flags & flag));
|
|
@@ -58650,11 +58649,11 @@ ${lanes.join("\n")}
|
|
|
58650
58649
|
if (includes & 1048576 /* Union */) {
|
|
58651
58650
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
58652
58651
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
58653
|
-
} else if (
|
|
58652
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
58654
58653
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
58655
58654
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
58656
58655
|
result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58657
|
-
} else if (
|
|
58656
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
58658
58657
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
58659
58658
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58660
58659
|
} else {
|
|
@@ -61042,8 +61041,20 @@ ${lanes.join("\n")}
|
|
|
61042
61041
|
return result;
|
|
61043
61042
|
}
|
|
61044
61043
|
const moreThanOneRealChildren = length(validChildren) > 1;
|
|
61045
|
-
|
|
61046
|
-
|
|
61044
|
+
let arrayLikeTargetParts;
|
|
61045
|
+
let nonArrayLikeTargetParts;
|
|
61046
|
+
const iterableType = getGlobalIterableType(
|
|
61047
|
+
/*reportErrors*/
|
|
61048
|
+
false
|
|
61049
|
+
);
|
|
61050
|
+
if (iterableType !== emptyGenericType) {
|
|
61051
|
+
const anyIterable = createIterableType(anyType);
|
|
61052
|
+
arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
|
|
61053
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
|
|
61054
|
+
} else {
|
|
61055
|
+
arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
|
|
61056
|
+
nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
|
|
61057
|
+
}
|
|
61047
61058
|
if (moreThanOneRealChildren) {
|
|
61048
61059
|
if (arrayLikeTargetParts !== neverType) {
|
|
61049
61060
|
const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
|
|
@@ -62167,6 +62178,11 @@ ${lanes.join("\n")}
|
|
|
62167
62178
|
if (containsType(targetTypes, source2)) {
|
|
62168
62179
|
return -1 /* True */;
|
|
62169
62180
|
}
|
|
62181
|
+
if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
|
|
62182
|
+
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
62183
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
62184
|
+
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
62185
|
+
}
|
|
62170
62186
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
62171
62187
|
if (match) {
|
|
62172
62188
|
const related = isRelatedTo(
|
|
@@ -64323,13 +64339,6 @@ ${lanes.join("\n")}
|
|
|
64323
64339
|
function isArrayOrTupleLikeType(type) {
|
|
64324
64340
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
64325
64341
|
}
|
|
64326
|
-
function isAssignableToAvailableAnyIterable(type) {
|
|
64327
|
-
const anyIterable = getGlobalIterableType(
|
|
64328
|
-
/*reportErrors*/
|
|
64329
|
-
false
|
|
64330
|
-
) !== emptyGenericType && createIterableType(anyType);
|
|
64331
|
-
return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
|
|
64332
|
-
}
|
|
64333
64342
|
function getTupleElementType(type, index) {
|
|
64334
64343
|
const propType = getTypeOfPropertyOfType(type, "" + index);
|
|
64335
64344
|
if (propType) {
|
|
@@ -68927,7 +68936,7 @@ ${lanes.join("\n")}
|
|
|
68927
68936
|
return void 0;
|
|
68928
68937
|
}
|
|
68929
68938
|
}
|
|
68930
|
-
return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
68939
|
+
return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
|
|
68931
68940
|
}
|
|
68932
68941
|
case 1 /* ExportsProperty */:
|
|
68933
68942
|
case 6 /* Prototype */:
|
|
@@ -69083,7 +69092,7 @@ ${lanes.join("\n")}
|
|
|
69083
69092
|
return void 0;
|
|
69084
69093
|
}
|
|
69085
69094
|
function getContextualTypeForElementExpression(arrayContextualType, index) {
|
|
69086
|
-
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(
|
|
69095
|
+
return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
|
|
69087
69096
|
arrayContextualType,
|
|
69088
69097
|
(t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
|
|
69089
69098
|
t,
|
|
@@ -69825,7 +69834,7 @@ ${lanes.join("\n")}
|
|
|
69825
69834
|
const inConstContext = isConstContext(node);
|
|
69826
69835
|
const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
|
|
69827
69836
|
const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
|
|
69828
|
-
const enumTag = getJSDocEnumTag(node);
|
|
69837
|
+
const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
|
|
69829
69838
|
const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
|
|
69830
69839
|
let objectFlags = freshObjectLiteralFlag;
|
|
69831
69840
|
let patternWithComputedProperties = false;
|
|
@@ -73531,6 +73540,12 @@ ${lanes.join("\n")}
|
|
|
73531
73540
|
function checkExpressionWithTypeArguments(node) {
|
|
73532
73541
|
checkGrammarExpressionWithTypeArguments(node);
|
|
73533
73542
|
forEach(node.typeArguments, checkSourceElement);
|
|
73543
|
+
if (node.kind === 231 /* ExpressionWithTypeArguments */) {
|
|
73544
|
+
const parent2 = walkUpParenthesizedExpressions(node.parent);
|
|
73545
|
+
if (parent2.kind === 224 /* BinaryExpression */ && parent2.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
|
|
73546
|
+
error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
|
|
73547
|
+
}
|
|
73548
|
+
}
|
|
73534
73549
|
const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
|
|
73535
73550
|
return getInstantiationExpressionType(exprType, node);
|
|
73536
73551
|
}
|
|
@@ -74488,7 +74503,7 @@ ${lanes.join("\n")}
|
|
|
74488
74503
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
74489
74504
|
const functionFlags = getFunctionFlags(func);
|
|
74490
74505
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
74491
|
-
if (type && maybeTypeOfKind(type,
|
|
74506
|
+
if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
|
|
74492
74507
|
return;
|
|
74493
74508
|
}
|
|
74494
74509
|
if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -74499,8 +74514,12 @@ ${lanes.join("\n")}
|
|
|
74499
74514
|
if (type && type.flags & 131072 /* Never */) {
|
|
74500
74515
|
error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
74501
74516
|
} else if (type && !hasExplicitReturn) {
|
|
74502
|
-
|
|
74503
|
-
|
|
74517
|
+
if (strictNullChecks) {
|
|
74518
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
|
|
74519
|
+
} else {
|
|
74520
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
74521
|
+
}
|
|
74522
|
+
} else if (type && strictNullChecks) {
|
|
74504
74523
|
error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
74505
74524
|
} else if (compilerOptions.noImplicitReturns) {
|
|
74506
74525
|
if (!type) {
|
|
@@ -74582,6 +74601,11 @@ ${lanes.join("\n")}
|
|
|
74582
74601
|
} else {
|
|
74583
74602
|
assignNonContextualParameterTypes(signature);
|
|
74584
74603
|
}
|
|
74604
|
+
} else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
|
|
74605
|
+
const inferenceContext = getInferenceContext(node);
|
|
74606
|
+
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
74607
|
+
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
74608
|
+
}
|
|
74585
74609
|
}
|
|
74586
74610
|
if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
|
|
74587
74611
|
const returnType = getReturnTypeFromBody(node, checkMode);
|
|
@@ -82187,12 +82211,35 @@ ${lanes.join("\n")}
|
|
|
82187
82211
|
}
|
|
82188
82212
|
return void 0;
|
|
82189
82213
|
}
|
|
82214
|
+
function isThisPropertyAndThisTyped(node) {
|
|
82215
|
+
if (node.expression.kind === 109 /* ThisKeyword */) {
|
|
82216
|
+
const container = getThisContainer(
|
|
82217
|
+
node,
|
|
82218
|
+
/*includeArrowFunctions*/
|
|
82219
|
+
false,
|
|
82220
|
+
/*includeClassComputedPropertyName*/
|
|
82221
|
+
false
|
|
82222
|
+
);
|
|
82223
|
+
if (isFunctionLike(container)) {
|
|
82224
|
+
const containingLiteral = getContainingObjectLiteral(container);
|
|
82225
|
+
if (containingLiteral) {
|
|
82226
|
+
const contextualType = getApparentTypeOfContextualType(
|
|
82227
|
+
containingLiteral,
|
|
82228
|
+
/*contextFlags*/
|
|
82229
|
+
void 0
|
|
82230
|
+
);
|
|
82231
|
+
const type = contextualType && getThisTypeFromContextualType(contextualType);
|
|
82232
|
+
return type && !isTypeAny(type);
|
|
82233
|
+
}
|
|
82234
|
+
}
|
|
82235
|
+
}
|
|
82236
|
+
}
|
|
82190
82237
|
function getSymbolOfNameOrPropertyAccessExpression(name) {
|
|
82191
82238
|
if (isDeclarationName(name)) {
|
|
82192
82239
|
return getSymbolOfNode(name.parent);
|
|
82193
82240
|
}
|
|
82194
82241
|
if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
|
|
82195
|
-
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
|
|
82242
|
+
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
|
|
82196
82243
|
const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
|
|
82197
82244
|
if (specialPropertyAssignmentSymbol) {
|
|
82198
82245
|
return specialPropertyAssignmentSymbol;
|
|
@@ -142397,6 +142444,7 @@ ${lanes.join("\n")}
|
|
|
142397
142444
|
const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
|
|
142398
142445
|
switch (errorCode) {
|
|
142399
142446
|
case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
|
|
142447
|
+
case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
|
|
142400
142448
|
if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
|
|
142401
142449
|
return void 0;
|
|
142402
142450
|
return getFixInfo(
|
|
@@ -142504,6 +142552,7 @@ ${lanes.join("\n")}
|
|
|
142504
142552
|
fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
142505
142553
|
errorCodes26 = [
|
|
142506
142554
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
142555
|
+
Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
|
|
142507
142556
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
142508
142557
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
142509
142558
|
];
|
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.1";
|
|
57
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
57
|
+
var version = `${versionMajorMinor}.0-dev.20230318`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -3127,7 +3127,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3127
3127
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
3128
3128
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
3129
3129
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
3130
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
3130
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
3131
3131
|
return TypeFlags2;
|
|
3132
3132
|
})(TypeFlags || {});
|
|
3133
3133
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -6012,6 +6012,8 @@ var Diagnostics = {
|
|
|
6012
6012
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
6013
6013
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
6014
6014
|
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
6015
|
+
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
6016
|
+
The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
|
|
6015
6017
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
6016
6018
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
6017
6019
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
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.1.0-dev.
|
|
5
|
+
"version": "5.1.0-dev.20230318",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"node-fetch": "^3.2.10",
|
|
80
80
|
"source-map-support": "^0.5.21",
|
|
81
81
|
"tslib": "^2.5.0",
|
|
82
|
-
"typescript": "5.0.
|
|
82
|
+
"typescript": "^5.0.2",
|
|
83
83
|
"which": "^2.0.2"
|
|
84
84
|
},
|
|
85
85
|
"overrides": {
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"node": "14.21.1",
|
|
114
114
|
"npm": "8.19.3"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "905a0b4e693e8cc13a726ad650b908fee4f75408"
|
|
117
117
|
}
|