typescript 5.2.0-dev.20230725 → 5.2.0-dev.20230727
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 +40 -39
- package/lib/tsserver.js +40 -39
- package/lib/tsserverlibrary.js +40 -39
- package/lib/typescript.js +40 -39
- 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.20230727`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -5764,6 +5764,7 @@ var Diagnostics = {
|
|
|
5764
5764
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
5765
5765
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
5766
5766
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
|
|
5767
|
+
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
|
|
5767
5768
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
5768
5769
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
5769
5770
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
|
@@ -55014,7 +55015,7 @@ function createTypeChecker(host) {
|
|
|
55014
55015
|
return getReturnTypeOfTypeTag(declaration);
|
|
55015
55016
|
}
|
|
55016
55017
|
function isResolvingReturnTypeOfSignature(signature) {
|
|
55017
|
-
return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
55018
|
+
return signature.compositeSignatures && some(signature.compositeSignatures, isResolvingReturnTypeOfSignature) || !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
55018
55019
|
}
|
|
55019
55020
|
function getRestTypeOfSignature(signature) {
|
|
55020
55021
|
return tryGetRestTypeOfSignature(signature) || anyType;
|
|
@@ -61158,26 +61159,6 @@ function createTypeChecker(host) {
|
|
|
61158
61159
|
)) {
|
|
61159
61160
|
return result2;
|
|
61160
61161
|
}
|
|
61161
|
-
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
61162
|
-
const indexType = source2.indexType;
|
|
61163
|
-
if (indexType.flags & 4194304 /* Index */) {
|
|
61164
|
-
const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
|
|
61165
|
-
const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
|
|
61166
|
-
const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
|
|
61167
|
-
if (result2 = isRelatedTo(
|
|
61168
|
-
constraint2,
|
|
61169
|
-
target2,
|
|
61170
|
-
1 /* Source */,
|
|
61171
|
-
/*reportErrors*/
|
|
61172
|
-
false,
|
|
61173
|
-
/*headMessage*/
|
|
61174
|
-
void 0,
|
|
61175
|
-
intersectionState
|
|
61176
|
-
)) {
|
|
61177
|
-
return result2;
|
|
61178
|
-
}
|
|
61179
|
-
}
|
|
61180
|
-
}
|
|
61181
61162
|
if (isMappedTypeGenericIndexedAccess(source2)) {
|
|
61182
61163
|
const indexConstraint = getConstraintOfType(source2.indexType);
|
|
61183
61164
|
if (indexConstraint) {
|
|
@@ -74986,7 +74967,18 @@ function createTypeChecker(host) {
|
|
|
74986
74967
|
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
74987
74968
|
function checkSignatureDeclarationDiagnostics() {
|
|
74988
74969
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
74989
|
-
|
|
74970
|
+
let returnTypeNode = getEffectiveReturnTypeNode(node);
|
|
74971
|
+
let returnTypeErrorLocation = returnTypeNode;
|
|
74972
|
+
if (isInJSFile(node)) {
|
|
74973
|
+
const typeTag = getJSDocTypeTag(node);
|
|
74974
|
+
if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
|
|
74975
|
+
const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
74976
|
+
if (signature && signature.declaration) {
|
|
74977
|
+
returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
|
|
74978
|
+
returnTypeErrorLocation = typeTag.typeExpression.type;
|
|
74979
|
+
}
|
|
74980
|
+
}
|
|
74981
|
+
}
|
|
74990
74982
|
if (noImplicitAny && !returnTypeNode) {
|
|
74991
74983
|
switch (node.kind) {
|
|
74992
74984
|
case 180 /* ConstructSignature */:
|
|
@@ -74997,21 +74989,21 @@ function createTypeChecker(host) {
|
|
|
74997
74989
|
break;
|
|
74998
74990
|
}
|
|
74999
74991
|
}
|
|
75000
|
-
if (returnTypeNode) {
|
|
74992
|
+
if (returnTypeNode && returnTypeErrorLocation) {
|
|
75001
74993
|
const functionFlags2 = getFunctionFlags(node);
|
|
75002
74994
|
if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
|
|
75003
74995
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
75004
74996
|
if (returnType === voidType) {
|
|
75005
|
-
error(
|
|
74997
|
+
error(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
|
|
75006
74998
|
} else {
|
|
75007
74999
|
const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
|
|
75008
75000
|
const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
|
|
75009
75001
|
const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
|
|
75010
75002
|
const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
|
|
75011
|
-
checkTypeAssignableTo(generatorInstantiation, returnType,
|
|
75003
|
+
checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
|
|
75012
75004
|
}
|
|
75013
75005
|
} else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
75014
|
-
checkAsyncFunctionReturnType(node, returnTypeNode);
|
|
75006
|
+
checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
|
|
75015
75007
|
}
|
|
75016
75008
|
}
|
|
75017
75009
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
@@ -76093,7 +76085,7 @@ function createTypeChecker(host) {
|
|
|
76093
76085
|
}
|
|
76094
76086
|
return typeAsAwaitable.awaitedTypeOfType = type;
|
|
76095
76087
|
}
|
|
76096
|
-
function checkAsyncFunctionReturnType(node, returnTypeNode) {
|
|
76088
|
+
function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
|
|
76097
76089
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
76098
76090
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
76099
76091
|
if (isErrorType(returnType)) {
|
|
@@ -76104,7 +76096,7 @@ function createTypeChecker(host) {
|
|
|
76104
76096
|
true
|
|
76105
76097
|
);
|
|
76106
76098
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
|
|
76107
|
-
|
|
76099
|
+
reportErrorForInvalidReturnType(Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, returnTypeNode, returnTypeErrorLocation, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
76108
76100
|
return;
|
|
76109
76101
|
}
|
|
76110
76102
|
} else {
|
|
@@ -76114,7 +76106,7 @@ function createTypeChecker(host) {
|
|
|
76114
76106
|
}
|
|
76115
76107
|
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
|
|
76116
76108
|
if (promiseConstructorName === void 0) {
|
|
76117
|
-
|
|
76109
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
|
|
76118
76110
|
return;
|
|
76119
76111
|
}
|
|
76120
76112
|
const promiseConstructorSymbol = resolveEntityName(
|
|
@@ -76129,9 +76121,9 @@ function createTypeChecker(host) {
|
|
|
76129
76121
|
/*reportErrors*/
|
|
76130
76122
|
false
|
|
76131
76123
|
)) {
|
|
76132
|
-
error(
|
|
76124
|
+
error(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
76133
76125
|
} else {
|
|
76134
|
-
|
|
76126
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
76135
76127
|
}
|
|
76136
76128
|
return;
|
|
76137
76129
|
}
|
|
@@ -76140,15 +76132,16 @@ function createTypeChecker(host) {
|
|
|
76140
76132
|
true
|
|
76141
76133
|
);
|
|
76142
76134
|
if (globalPromiseConstructorLikeType === emptyObjectType) {
|
|
76143
|
-
|
|
76135
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
76144
76136
|
return;
|
|
76145
76137
|
}
|
|
76146
|
-
|
|
76147
|
-
|
|
76148
|
-
|
|
76149
|
-
|
|
76150
|
-
Diagnostics.
|
|
76151
|
-
)
|
|
76138
|
+
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
|
|
76139
|
+
const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
|
|
76140
|
+
/*details*/
|
|
76141
|
+
void 0,
|
|
76142
|
+
Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
|
|
76143
|
+
);
|
|
76144
|
+
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
|
|
76152
76145
|
return;
|
|
76153
76146
|
}
|
|
76154
76147
|
const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
|
|
@@ -76170,6 +76163,14 @@ function createTypeChecker(host) {
|
|
|
76170
76163
|
node,
|
|
76171
76164
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
76172
76165
|
);
|
|
76166
|
+
function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
|
|
76167
|
+
if (returnTypeNode2 === returnTypeErrorLocation2) {
|
|
76168
|
+
error(returnTypeErrorLocation2, message, typeName);
|
|
76169
|
+
} else {
|
|
76170
|
+
const diag2 = error(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
|
76171
|
+
addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
|
|
76172
|
+
}
|
|
76173
|
+
}
|
|
76173
76174
|
}
|
|
76174
76175
|
function checkDecorator(node) {
|
|
76175
76176
|
const signature = getResolvedSignature(node);
|
package/lib/tsserver.js
CHANGED
|
@@ -2329,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2329
2329
|
|
|
2330
2330
|
// src/compiler/corePublic.ts
|
|
2331
2331
|
var versionMajorMinor = "5.2";
|
|
2332
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2332
|
+
var version = `${versionMajorMinor}.0-dev.20230727`;
|
|
2333
2333
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2334
2334
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2335
2335
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9287,6 +9287,7 @@ var Diagnostics = {
|
|
|
9287
9287
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
9288
9288
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
9289
9289
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
|
|
9290
|
+
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
|
|
9290
9291
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
9291
9292
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
9292
9293
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
|
@@ -59723,7 +59724,7 @@ function createTypeChecker(host) {
|
|
|
59723
59724
|
return getReturnTypeOfTypeTag(declaration);
|
|
59724
59725
|
}
|
|
59725
59726
|
function isResolvingReturnTypeOfSignature(signature) {
|
|
59726
|
-
return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
59727
|
+
return signature.compositeSignatures && some(signature.compositeSignatures, isResolvingReturnTypeOfSignature) || !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
59727
59728
|
}
|
|
59728
59729
|
function getRestTypeOfSignature(signature) {
|
|
59729
59730
|
return tryGetRestTypeOfSignature(signature) || anyType;
|
|
@@ -65867,26 +65868,6 @@ function createTypeChecker(host) {
|
|
|
65867
65868
|
)) {
|
|
65868
65869
|
return result2;
|
|
65869
65870
|
}
|
|
65870
|
-
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
65871
|
-
const indexType = source2.indexType;
|
|
65872
|
-
if (indexType.flags & 4194304 /* Index */) {
|
|
65873
|
-
const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
|
|
65874
|
-
const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
|
|
65875
|
-
const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
|
|
65876
|
-
if (result2 = isRelatedTo(
|
|
65877
|
-
constraint2,
|
|
65878
|
-
target2,
|
|
65879
|
-
1 /* Source */,
|
|
65880
|
-
/*reportErrors*/
|
|
65881
|
-
false,
|
|
65882
|
-
/*headMessage*/
|
|
65883
|
-
void 0,
|
|
65884
|
-
intersectionState
|
|
65885
|
-
)) {
|
|
65886
|
-
return result2;
|
|
65887
|
-
}
|
|
65888
|
-
}
|
|
65889
|
-
}
|
|
65890
65871
|
if (isMappedTypeGenericIndexedAccess(source2)) {
|
|
65891
65872
|
const indexConstraint = getConstraintOfType(source2.indexType);
|
|
65892
65873
|
if (indexConstraint) {
|
|
@@ -79695,7 +79676,18 @@ function createTypeChecker(host) {
|
|
|
79695
79676
|
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
79696
79677
|
function checkSignatureDeclarationDiagnostics() {
|
|
79697
79678
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
79698
|
-
|
|
79679
|
+
let returnTypeNode = getEffectiveReturnTypeNode(node);
|
|
79680
|
+
let returnTypeErrorLocation = returnTypeNode;
|
|
79681
|
+
if (isInJSFile(node)) {
|
|
79682
|
+
const typeTag = getJSDocTypeTag(node);
|
|
79683
|
+
if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
|
|
79684
|
+
const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
79685
|
+
if (signature && signature.declaration) {
|
|
79686
|
+
returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
|
|
79687
|
+
returnTypeErrorLocation = typeTag.typeExpression.type;
|
|
79688
|
+
}
|
|
79689
|
+
}
|
|
79690
|
+
}
|
|
79699
79691
|
if (noImplicitAny && !returnTypeNode) {
|
|
79700
79692
|
switch (node.kind) {
|
|
79701
79693
|
case 180 /* ConstructSignature */:
|
|
@@ -79706,21 +79698,21 @@ function createTypeChecker(host) {
|
|
|
79706
79698
|
break;
|
|
79707
79699
|
}
|
|
79708
79700
|
}
|
|
79709
|
-
if (returnTypeNode) {
|
|
79701
|
+
if (returnTypeNode && returnTypeErrorLocation) {
|
|
79710
79702
|
const functionFlags2 = getFunctionFlags(node);
|
|
79711
79703
|
if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
|
|
79712
79704
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
79713
79705
|
if (returnType === voidType) {
|
|
79714
|
-
error2(
|
|
79706
|
+
error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
|
|
79715
79707
|
} else {
|
|
79716
79708
|
const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
|
|
79717
79709
|
const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
|
|
79718
79710
|
const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
|
|
79719
79711
|
const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
|
|
79720
|
-
checkTypeAssignableTo(generatorInstantiation, returnType,
|
|
79712
|
+
checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
|
|
79721
79713
|
}
|
|
79722
79714
|
} else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
79723
|
-
checkAsyncFunctionReturnType(node, returnTypeNode);
|
|
79715
|
+
checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
|
|
79724
79716
|
}
|
|
79725
79717
|
}
|
|
79726
79718
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
@@ -80802,7 +80794,7 @@ function createTypeChecker(host) {
|
|
|
80802
80794
|
}
|
|
80803
80795
|
return typeAsAwaitable.awaitedTypeOfType = type;
|
|
80804
80796
|
}
|
|
80805
|
-
function checkAsyncFunctionReturnType(node, returnTypeNode) {
|
|
80797
|
+
function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
|
|
80806
80798
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
80807
80799
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
80808
80800
|
if (isErrorType(returnType)) {
|
|
@@ -80813,7 +80805,7 @@ function createTypeChecker(host) {
|
|
|
80813
80805
|
true
|
|
80814
80806
|
);
|
|
80815
80807
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType2(returnType, globalPromiseType)) {
|
|
80816
|
-
|
|
80808
|
+
reportErrorForInvalidReturnType(Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, returnTypeNode, returnTypeErrorLocation, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
80817
80809
|
return;
|
|
80818
80810
|
}
|
|
80819
80811
|
} else {
|
|
@@ -80823,7 +80815,7 @@ function createTypeChecker(host) {
|
|
|
80823
80815
|
}
|
|
80824
80816
|
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
|
|
80825
80817
|
if (promiseConstructorName === void 0) {
|
|
80826
|
-
|
|
80818
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
|
|
80827
80819
|
return;
|
|
80828
80820
|
}
|
|
80829
80821
|
const promiseConstructorSymbol = resolveEntityName(
|
|
@@ -80838,9 +80830,9 @@ function createTypeChecker(host) {
|
|
|
80838
80830
|
/*reportErrors*/
|
|
80839
80831
|
false
|
|
80840
80832
|
)) {
|
|
80841
|
-
error2(
|
|
80833
|
+
error2(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
80842
80834
|
} else {
|
|
80843
|
-
|
|
80835
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
80844
80836
|
}
|
|
80845
80837
|
return;
|
|
80846
80838
|
}
|
|
@@ -80849,15 +80841,16 @@ function createTypeChecker(host) {
|
|
|
80849
80841
|
true
|
|
80850
80842
|
);
|
|
80851
80843
|
if (globalPromiseConstructorLikeType === emptyObjectType) {
|
|
80852
|
-
|
|
80844
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
80853
80845
|
return;
|
|
80854
80846
|
}
|
|
80855
|
-
|
|
80856
|
-
|
|
80857
|
-
|
|
80858
|
-
|
|
80859
|
-
Diagnostics.
|
|
80860
|
-
)
|
|
80847
|
+
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
|
|
80848
|
+
const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
|
|
80849
|
+
/*details*/
|
|
80850
|
+
void 0,
|
|
80851
|
+
Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
|
|
80852
|
+
);
|
|
80853
|
+
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
|
|
80861
80854
|
return;
|
|
80862
80855
|
}
|
|
80863
80856
|
const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
|
|
@@ -80879,6 +80872,14 @@ function createTypeChecker(host) {
|
|
|
80879
80872
|
node,
|
|
80880
80873
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
80881
80874
|
);
|
|
80875
|
+
function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
|
|
80876
|
+
if (returnTypeNode2 === returnTypeErrorLocation2) {
|
|
80877
|
+
error2(returnTypeErrorLocation2, message, typeName);
|
|
80878
|
+
} else {
|
|
80879
|
+
const diag2 = error2(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
|
80880
|
+
addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
|
|
80881
|
+
}
|
|
80882
|
+
}
|
|
80882
80883
|
}
|
|
80883
80884
|
function checkDecorator(node) {
|
|
80884
80885
|
const signature = getResolvedSignature(node);
|
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.20230727`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -7068,6 +7068,7 @@ ${lanes.join("\n")}
|
|
|
7068
7068
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
7069
7069
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
7070
7070
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
|
|
7071
|
+
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
|
|
7071
7072
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
7072
7073
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
7073
7074
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
|
@@ -57488,7 +57489,7 @@ ${lanes.join("\n")}
|
|
|
57488
57489
|
return getReturnTypeOfTypeTag(declaration);
|
|
57489
57490
|
}
|
|
57490
57491
|
function isResolvingReturnTypeOfSignature(signature) {
|
|
57491
|
-
return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
57492
|
+
return signature.compositeSignatures && some(signature.compositeSignatures, isResolvingReturnTypeOfSignature) || !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
57492
57493
|
}
|
|
57493
57494
|
function getRestTypeOfSignature(signature) {
|
|
57494
57495
|
return tryGetRestTypeOfSignature(signature) || anyType;
|
|
@@ -63632,26 +63633,6 @@ ${lanes.join("\n")}
|
|
|
63632
63633
|
)) {
|
|
63633
63634
|
return result2;
|
|
63634
63635
|
}
|
|
63635
|
-
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
63636
|
-
const indexType = source2.indexType;
|
|
63637
|
-
if (indexType.flags & 4194304 /* Index */) {
|
|
63638
|
-
const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
|
|
63639
|
-
const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
|
|
63640
|
-
const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
|
|
63641
|
-
if (result2 = isRelatedTo(
|
|
63642
|
-
constraint2,
|
|
63643
|
-
target2,
|
|
63644
|
-
1 /* Source */,
|
|
63645
|
-
/*reportErrors*/
|
|
63646
|
-
false,
|
|
63647
|
-
/*headMessage*/
|
|
63648
|
-
void 0,
|
|
63649
|
-
intersectionState
|
|
63650
|
-
)) {
|
|
63651
|
-
return result2;
|
|
63652
|
-
}
|
|
63653
|
-
}
|
|
63654
|
-
}
|
|
63655
63636
|
if (isMappedTypeGenericIndexedAccess(source2)) {
|
|
63656
63637
|
const indexConstraint = getConstraintOfType(source2.indexType);
|
|
63657
63638
|
if (indexConstraint) {
|
|
@@ -77460,7 +77441,18 @@ ${lanes.join("\n")}
|
|
|
77460
77441
|
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
77461
77442
|
function checkSignatureDeclarationDiagnostics() {
|
|
77462
77443
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
77463
|
-
|
|
77444
|
+
let returnTypeNode = getEffectiveReturnTypeNode(node);
|
|
77445
|
+
let returnTypeErrorLocation = returnTypeNode;
|
|
77446
|
+
if (isInJSFile(node)) {
|
|
77447
|
+
const typeTag = getJSDocTypeTag(node);
|
|
77448
|
+
if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
|
|
77449
|
+
const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
77450
|
+
if (signature && signature.declaration) {
|
|
77451
|
+
returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
|
|
77452
|
+
returnTypeErrorLocation = typeTag.typeExpression.type;
|
|
77453
|
+
}
|
|
77454
|
+
}
|
|
77455
|
+
}
|
|
77464
77456
|
if (noImplicitAny && !returnTypeNode) {
|
|
77465
77457
|
switch (node.kind) {
|
|
77466
77458
|
case 180 /* ConstructSignature */:
|
|
@@ -77471,21 +77463,21 @@ ${lanes.join("\n")}
|
|
|
77471
77463
|
break;
|
|
77472
77464
|
}
|
|
77473
77465
|
}
|
|
77474
|
-
if (returnTypeNode) {
|
|
77466
|
+
if (returnTypeNode && returnTypeErrorLocation) {
|
|
77475
77467
|
const functionFlags2 = getFunctionFlags(node);
|
|
77476
77468
|
if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
|
|
77477
77469
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
77478
77470
|
if (returnType === voidType) {
|
|
77479
|
-
error2(
|
|
77471
|
+
error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
|
|
77480
77472
|
} else {
|
|
77481
77473
|
const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
|
|
77482
77474
|
const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
|
|
77483
77475
|
const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
|
|
77484
77476
|
const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
|
|
77485
|
-
checkTypeAssignableTo(generatorInstantiation, returnType,
|
|
77477
|
+
checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
|
|
77486
77478
|
}
|
|
77487
77479
|
} else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
77488
|
-
checkAsyncFunctionReturnType(node, returnTypeNode);
|
|
77480
|
+
checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
|
|
77489
77481
|
}
|
|
77490
77482
|
}
|
|
77491
77483
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
@@ -78567,7 +78559,7 @@ ${lanes.join("\n")}
|
|
|
78567
78559
|
}
|
|
78568
78560
|
return typeAsAwaitable.awaitedTypeOfType = type;
|
|
78569
78561
|
}
|
|
78570
|
-
function checkAsyncFunctionReturnType(node, returnTypeNode) {
|
|
78562
|
+
function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
|
|
78571
78563
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78572
78564
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78573
78565
|
if (isErrorType(returnType)) {
|
|
@@ -78578,7 +78570,7 @@ ${lanes.join("\n")}
|
|
|
78578
78570
|
true
|
|
78579
78571
|
);
|
|
78580
78572
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType2(returnType, globalPromiseType)) {
|
|
78581
|
-
|
|
78573
|
+
reportErrorForInvalidReturnType(Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, returnTypeNode, returnTypeErrorLocation, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
78582
78574
|
return;
|
|
78583
78575
|
}
|
|
78584
78576
|
} else {
|
|
@@ -78588,7 +78580,7 @@ ${lanes.join("\n")}
|
|
|
78588
78580
|
}
|
|
78589
78581
|
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
|
|
78590
78582
|
if (promiseConstructorName === void 0) {
|
|
78591
|
-
|
|
78583
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
|
|
78592
78584
|
return;
|
|
78593
78585
|
}
|
|
78594
78586
|
const promiseConstructorSymbol = resolveEntityName(
|
|
@@ -78603,9 +78595,9 @@ ${lanes.join("\n")}
|
|
|
78603
78595
|
/*reportErrors*/
|
|
78604
78596
|
false
|
|
78605
78597
|
)) {
|
|
78606
|
-
error2(
|
|
78598
|
+
error2(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
78607
78599
|
} else {
|
|
78608
|
-
|
|
78600
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
78609
78601
|
}
|
|
78610
78602
|
return;
|
|
78611
78603
|
}
|
|
@@ -78614,15 +78606,16 @@ ${lanes.join("\n")}
|
|
|
78614
78606
|
true
|
|
78615
78607
|
);
|
|
78616
78608
|
if (globalPromiseConstructorLikeType === emptyObjectType) {
|
|
78617
|
-
|
|
78609
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
78618
78610
|
return;
|
|
78619
78611
|
}
|
|
78620
|
-
|
|
78621
|
-
|
|
78622
|
-
|
|
78623
|
-
|
|
78624
|
-
Diagnostics.
|
|
78625
|
-
)
|
|
78612
|
+
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
|
|
78613
|
+
const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
|
|
78614
|
+
/*details*/
|
|
78615
|
+
void 0,
|
|
78616
|
+
Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
|
|
78617
|
+
);
|
|
78618
|
+
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
|
|
78626
78619
|
return;
|
|
78627
78620
|
}
|
|
78628
78621
|
const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
|
|
@@ -78644,6 +78637,14 @@ ${lanes.join("\n")}
|
|
|
78644
78637
|
node,
|
|
78645
78638
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
78646
78639
|
);
|
|
78640
|
+
function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
|
|
78641
|
+
if (returnTypeNode2 === returnTypeErrorLocation2) {
|
|
78642
|
+
error2(returnTypeErrorLocation2, message, typeName);
|
|
78643
|
+
} else {
|
|
78644
|
+
const diag2 = error2(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
|
78645
|
+
addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
|
|
78646
|
+
}
|
|
78647
|
+
}
|
|
78647
78648
|
}
|
|
78648
78649
|
function checkDecorator(node) {
|
|
78649
78650
|
const signature = getResolvedSignature(node);
|
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.20230727`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -7068,6 +7068,7 @@ ${lanes.join("\n")}
|
|
|
7068
7068
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
7069
7069
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
7070
7070
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
|
|
7071
|
+
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
|
|
7071
7072
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
7072
7073
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
7073
7074
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
|
@@ -57488,7 +57489,7 @@ ${lanes.join("\n")}
|
|
|
57488
57489
|
return getReturnTypeOfTypeTag(declaration);
|
|
57489
57490
|
}
|
|
57490
57491
|
function isResolvingReturnTypeOfSignature(signature) {
|
|
57491
|
-
return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
57492
|
+
return signature.compositeSignatures && some(signature.compositeSignatures, isResolvingReturnTypeOfSignature) || !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
|
|
57492
57493
|
}
|
|
57493
57494
|
function getRestTypeOfSignature(signature) {
|
|
57494
57495
|
return tryGetRestTypeOfSignature(signature) || anyType;
|
|
@@ -63632,26 +63633,6 @@ ${lanes.join("\n")}
|
|
|
63632
63633
|
)) {
|
|
63633
63634
|
return result2;
|
|
63634
63635
|
}
|
|
63635
|
-
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
63636
|
-
const indexType = source2.indexType;
|
|
63637
|
-
if (indexType.flags & 4194304 /* Index */) {
|
|
63638
|
-
const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
|
|
63639
|
-
const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
|
|
63640
|
-
const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
|
|
63641
|
-
if (result2 = isRelatedTo(
|
|
63642
|
-
constraint2,
|
|
63643
|
-
target2,
|
|
63644
|
-
1 /* Source */,
|
|
63645
|
-
/*reportErrors*/
|
|
63646
|
-
false,
|
|
63647
|
-
/*headMessage*/
|
|
63648
|
-
void 0,
|
|
63649
|
-
intersectionState
|
|
63650
|
-
)) {
|
|
63651
|
-
return result2;
|
|
63652
|
-
}
|
|
63653
|
-
}
|
|
63654
|
-
}
|
|
63655
63636
|
if (isMappedTypeGenericIndexedAccess(source2)) {
|
|
63656
63637
|
const indexConstraint = getConstraintOfType(source2.indexType);
|
|
63657
63638
|
if (indexConstraint) {
|
|
@@ -77460,7 +77441,18 @@ ${lanes.join("\n")}
|
|
|
77460
77441
|
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
77461
77442
|
function checkSignatureDeclarationDiagnostics() {
|
|
77462
77443
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
77463
|
-
|
|
77444
|
+
let returnTypeNode = getEffectiveReturnTypeNode(node);
|
|
77445
|
+
let returnTypeErrorLocation = returnTypeNode;
|
|
77446
|
+
if (isInJSFile(node)) {
|
|
77447
|
+
const typeTag = getJSDocTypeTag(node);
|
|
77448
|
+
if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
|
|
77449
|
+
const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
77450
|
+
if (signature && signature.declaration) {
|
|
77451
|
+
returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
|
|
77452
|
+
returnTypeErrorLocation = typeTag.typeExpression.type;
|
|
77453
|
+
}
|
|
77454
|
+
}
|
|
77455
|
+
}
|
|
77464
77456
|
if (noImplicitAny && !returnTypeNode) {
|
|
77465
77457
|
switch (node.kind) {
|
|
77466
77458
|
case 180 /* ConstructSignature */:
|
|
@@ -77471,21 +77463,21 @@ ${lanes.join("\n")}
|
|
|
77471
77463
|
break;
|
|
77472
77464
|
}
|
|
77473
77465
|
}
|
|
77474
|
-
if (returnTypeNode) {
|
|
77466
|
+
if (returnTypeNode && returnTypeErrorLocation) {
|
|
77475
77467
|
const functionFlags2 = getFunctionFlags(node);
|
|
77476
77468
|
if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
|
|
77477
77469
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
77478
77470
|
if (returnType === voidType) {
|
|
77479
|
-
error2(
|
|
77471
|
+
error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
|
|
77480
77472
|
} else {
|
|
77481
77473
|
const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
|
|
77482
77474
|
const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
|
|
77483
77475
|
const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
|
|
77484
77476
|
const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
|
|
77485
|
-
checkTypeAssignableTo(generatorInstantiation, returnType,
|
|
77477
|
+
checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
|
|
77486
77478
|
}
|
|
77487
77479
|
} else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
77488
|
-
checkAsyncFunctionReturnType(node, returnTypeNode);
|
|
77480
|
+
checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
|
|
77489
77481
|
}
|
|
77490
77482
|
}
|
|
77491
77483
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
@@ -78567,7 +78559,7 @@ ${lanes.join("\n")}
|
|
|
78567
78559
|
}
|
|
78568
78560
|
return typeAsAwaitable.awaitedTypeOfType = type;
|
|
78569
78561
|
}
|
|
78570
|
-
function checkAsyncFunctionReturnType(node, returnTypeNode) {
|
|
78562
|
+
function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
|
|
78571
78563
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78572
78564
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78573
78565
|
if (isErrorType(returnType)) {
|
|
@@ -78578,7 +78570,7 @@ ${lanes.join("\n")}
|
|
|
78578
78570
|
true
|
|
78579
78571
|
);
|
|
78580
78572
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType2(returnType, globalPromiseType)) {
|
|
78581
|
-
|
|
78573
|
+
reportErrorForInvalidReturnType(Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, returnTypeNode, returnTypeErrorLocation, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
78582
78574
|
return;
|
|
78583
78575
|
}
|
|
78584
78576
|
} else {
|
|
@@ -78588,7 +78580,7 @@ ${lanes.join("\n")}
|
|
|
78588
78580
|
}
|
|
78589
78581
|
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
|
|
78590
78582
|
if (promiseConstructorName === void 0) {
|
|
78591
|
-
|
|
78583
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
|
|
78592
78584
|
return;
|
|
78593
78585
|
}
|
|
78594
78586
|
const promiseConstructorSymbol = resolveEntityName(
|
|
@@ -78603,9 +78595,9 @@ ${lanes.join("\n")}
|
|
|
78603
78595
|
/*reportErrors*/
|
|
78604
78596
|
false
|
|
78605
78597
|
)) {
|
|
78606
|
-
error2(
|
|
78598
|
+
error2(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
78607
78599
|
} else {
|
|
78608
|
-
|
|
78600
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
78609
78601
|
}
|
|
78610
78602
|
return;
|
|
78611
78603
|
}
|
|
@@ -78614,15 +78606,16 @@ ${lanes.join("\n")}
|
|
|
78614
78606
|
true
|
|
78615
78607
|
);
|
|
78616
78608
|
if (globalPromiseConstructorLikeType === emptyObjectType) {
|
|
78617
|
-
|
|
78609
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
78618
78610
|
return;
|
|
78619
78611
|
}
|
|
78620
|
-
|
|
78621
|
-
|
|
78622
|
-
|
|
78623
|
-
|
|
78624
|
-
Diagnostics.
|
|
78625
|
-
)
|
|
78612
|
+
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
|
|
78613
|
+
const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
|
|
78614
|
+
/*details*/
|
|
78615
|
+
void 0,
|
|
78616
|
+
Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
|
|
78617
|
+
);
|
|
78618
|
+
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
|
|
78626
78619
|
return;
|
|
78627
78620
|
}
|
|
78628
78621
|
const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
|
|
@@ -78644,6 +78637,14 @@ ${lanes.join("\n")}
|
|
|
78644
78637
|
node,
|
|
78645
78638
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
78646
78639
|
);
|
|
78640
|
+
function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
|
|
78641
|
+
if (returnTypeNode2 === returnTypeErrorLocation2) {
|
|
78642
|
+
error2(returnTypeErrorLocation2, message, typeName);
|
|
78643
|
+
} else {
|
|
78644
|
+
const diag2 = error2(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
|
78645
|
+
addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
|
|
78646
|
+
}
|
|
78647
|
+
}
|
|
78647
78648
|
}
|
|
78648
78649
|
function checkDecorator(node) {
|
|
78649
78650
|
const signature = getResolvedSignature(node);
|
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.20230727`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -5138,6 +5138,7 @@ var Diagnostics = {
|
|
|
5138
5138
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
5139
5139
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
5140
5140
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
|
|
5141
|
+
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
|
|
5141
5142
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
5142
5143
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
5143
5144
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
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.20230727",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"node": "20.1.0",
|
|
114
114
|
"npm": "8.19.4"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "c69f4476af93f9e3b3159c3fbcc5d629cda3efd8"
|
|
117
117
|
}
|