typescript 5.5.0-dev.20240424 → 5.5.0-dev.20240425
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 +129 -46
- package/lib/typescript.js +129 -46
- 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.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240425`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -6206,8 +6206,8 @@ var Diagnostics = {
|
|
|
6206
6206
|
Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1530, 1 /* Error */, "Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v__1530", "Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
|
|
6207
6207
|
_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces: diag(1531, 1 /* Error */, "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1531", "'\\{0}' must be followed by a Unicode property value expression enclosed in braces."),
|
|
6208
6208
|
There_is_no_capturing_group_named_0_in_this_regular_expression: diag(1532, 1 /* Error */, "There_is_no_capturing_group_named_0_in_this_regular_expression_1532", "There is no capturing group named '{0}' in this regular expression."),
|
|
6209
|
-
|
|
6210
|
-
|
|
6209
|
+
This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1533, 1 /* Error */, "This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_r_1533", "This backreference refers to a group that does not exist. There are only {0} capturing groups in this regular expression."),
|
|
6210
|
+
This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups: diag(1534, 1 /* Error */, "This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups_1534", "This backreference is invalid because the containing regular expression contains no capturing groups."),
|
|
6211
6211
|
This_character_cannot_be_escaped_in_a_regular_expression: diag(1535, 1 /* Error */, "This_character_cannot_be_escaped_in_a_regular_expression_1535", "This character cannot be escaped in a regular expression."),
|
|
6212
6212
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
6213
6213
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
@@ -9012,7 +9012,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9012
9012
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
9013
9013
|
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
9014
9014
|
const code = parseInt(text.substring(start2 + 1, pos), 8);
|
|
9015
|
-
|
|
9015
|
+
if (isRegularExpression !== "annex-b") {
|
|
9016
|
+
error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
|
|
9017
|
+
}
|
|
9016
9018
|
return String.fromCharCode(code);
|
|
9017
9019
|
}
|
|
9018
9020
|
return text.substring(start2, pos);
|
|
@@ -9043,7 +9045,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9043
9045
|
case 117 /* u */:
|
|
9044
9046
|
if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
9045
9047
|
pos -= 2;
|
|
9046
|
-
return scanExtendedUnicodeEscape(isRegularExpression || shouldEmitInvalidEscapeError);
|
|
9048
|
+
return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
|
|
9047
9049
|
}
|
|
9048
9050
|
for (; pos < start2 + 6; pos++) {
|
|
9049
9051
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
@@ -9093,7 +9095,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9093
9095
|
case 8233 /* paragraphSeparator */:
|
|
9094
9096
|
return "";
|
|
9095
9097
|
default:
|
|
9096
|
-
if (isRegularExpression && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
|
|
9098
|
+
if (isRegularExpression === true && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
|
|
9097
9099
|
error(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2);
|
|
9098
9100
|
}
|
|
9099
9101
|
return String.fromCharCode(ch);
|
|
@@ -9788,7 +9790,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9788
9790
|
pos = tokenStart + 1;
|
|
9789
9791
|
return token = 64 /* EqualsToken */;
|
|
9790
9792
|
}
|
|
9791
|
-
function reScanSlashToken() {
|
|
9793
|
+
function reScanSlashToken(reportErrors2) {
|
|
9792
9794
|
if (token === 44 /* SlashToken */ || token === 69 /* SlashEqualsToken */) {
|
|
9793
9795
|
let p = tokenStart + 1;
|
|
9794
9796
|
let inEscape = false;
|
|
@@ -9827,38 +9829,54 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9827
9829
|
if (!isIdentifierPart(ch, languageVersion)) {
|
|
9828
9830
|
break;
|
|
9829
9831
|
}
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9832
|
+
if (reportErrors2) {
|
|
9833
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
9834
|
+
if (flag === void 0) {
|
|
9835
|
+
error(Diagnostics.Unknown_regular_expression_flag, p, 1);
|
|
9836
|
+
} else if (regExpFlags & flag) {
|
|
9837
|
+
error(Diagnostics.Duplicate_regular_expression_flag, p, 1);
|
|
9838
|
+
} else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
|
|
9839
|
+
error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
|
|
9840
|
+
} else {
|
|
9841
|
+
regExpFlags |= flag;
|
|
9842
|
+
const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
|
|
9843
|
+
if (languageVersion < availableFrom) {
|
|
9844
|
+
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, getNameOfScriptTarget(availableFrom));
|
|
9845
|
+
}
|
|
9842
9846
|
}
|
|
9843
9847
|
}
|
|
9844
9848
|
p++;
|
|
9845
9849
|
}
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9850
|
+
if (reportErrors2) {
|
|
9851
|
+
pos = tokenStart + 1;
|
|
9852
|
+
const saveTokenPos = tokenStart;
|
|
9853
|
+
const saveTokenFlags = tokenFlags;
|
|
9854
|
+
scanRegularExpressionWorker(
|
|
9855
|
+
text,
|
|
9856
|
+
endOfBody,
|
|
9857
|
+
regExpFlags,
|
|
9858
|
+
isUnterminated,
|
|
9859
|
+
/*annexB*/
|
|
9860
|
+
true
|
|
9861
|
+
);
|
|
9862
|
+
if (!isUnterminated) {
|
|
9863
|
+
pos = p;
|
|
9864
|
+
}
|
|
9865
|
+
tokenStart = saveTokenPos;
|
|
9866
|
+
tokenFlags = saveTokenFlags;
|
|
9867
|
+
} else {
|
|
9851
9868
|
pos = p;
|
|
9852
9869
|
}
|
|
9853
|
-
tokenStart = saveTokenPos;
|
|
9854
|
-
tokenFlags = saveTokenFlags;
|
|
9855
9870
|
tokenValue = text.substring(tokenStart, pos);
|
|
9856
9871
|
token = 14 /* RegularExpressionLiteral */;
|
|
9857
9872
|
}
|
|
9858
9873
|
return token;
|
|
9859
|
-
function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated) {
|
|
9860
|
-
const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
9874
|
+
function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated, annexB) {
|
|
9861
9875
|
const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
|
|
9876
|
+
const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
9877
|
+
if (unicodeMode) {
|
|
9878
|
+
annexB = false;
|
|
9879
|
+
}
|
|
9862
9880
|
let mayContainStrings = false;
|
|
9863
9881
|
let numberOfCapturingGroups = 0;
|
|
9864
9882
|
const groupSpecifiers = /* @__PURE__ */ new Set();
|
|
@@ -9909,7 +9927,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9909
9927
|
case 61 /* equals */:
|
|
9910
9928
|
case 33 /* exclamation */:
|
|
9911
9929
|
pos++;
|
|
9912
|
-
isPreviousTermQuantifiable =
|
|
9930
|
+
isPreviousTermQuantifiable = annexB;
|
|
9913
9931
|
break;
|
|
9914
9932
|
case 60 /* lessThan */:
|
|
9915
9933
|
const groupNameStart = pos;
|
|
@@ -10088,7 +10106,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10088
10106
|
break;
|
|
10089
10107
|
}
|
|
10090
10108
|
default:
|
|
10091
|
-
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
|
|
10109
|
+
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
|
|
10110
|
+
/*atomEscape*/
|
|
10111
|
+
true
|
|
10112
|
+
));
|
|
10092
10113
|
break;
|
|
10093
10114
|
}
|
|
10094
10115
|
}
|
|
@@ -10103,7 +10124,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10103
10124
|
}
|
|
10104
10125
|
return false;
|
|
10105
10126
|
}
|
|
10106
|
-
function scanCharacterEscape() {
|
|
10127
|
+
function scanCharacterEscape(atomEscape) {
|
|
10107
10128
|
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10108
10129
|
let ch = text2.charCodeAt(pos);
|
|
10109
10130
|
switch (ch) {
|
|
@@ -10116,6 +10137,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10116
10137
|
}
|
|
10117
10138
|
if (unicodeMode) {
|
|
10118
10139
|
error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
|
|
10140
|
+
} else if (atomEscape && annexB) {
|
|
10141
|
+
pos--;
|
|
10142
|
+
return "\\";
|
|
10119
10143
|
}
|
|
10120
10144
|
return String.fromCharCode(ch);
|
|
10121
10145
|
case 94 /* caret */:
|
|
@@ -10145,7 +10169,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10145
10169
|
/*shouldEmitInvalidEscapeError*/
|
|
10146
10170
|
unicodeMode,
|
|
10147
10171
|
/*isRegularExpression*/
|
|
10148
|
-
true
|
|
10172
|
+
annexB ? "annex-b" : true
|
|
10149
10173
|
);
|
|
10150
10174
|
}
|
|
10151
10175
|
}
|
|
@@ -10185,12 +10209,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10185
10209
|
if (isClassContentExit(ch2)) {
|
|
10186
10210
|
return;
|
|
10187
10211
|
}
|
|
10188
|
-
if (!minCharacter) {
|
|
10212
|
+
if (!minCharacter && !annexB) {
|
|
10189
10213
|
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
|
|
10190
10214
|
}
|
|
10191
10215
|
const maxStart = pos;
|
|
10192
10216
|
const maxCharacter = scanClassAtom();
|
|
10193
|
-
if (!maxCharacter) {
|
|
10217
|
+
if (!maxCharacter && !annexB) {
|
|
10194
10218
|
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
|
|
10195
10219
|
continue;
|
|
10196
10220
|
}
|
|
@@ -10473,7 +10497,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10473
10497
|
pos++;
|
|
10474
10498
|
return String.fromCharCode(ch2);
|
|
10475
10499
|
default:
|
|
10476
|
-
return scanCharacterEscape(
|
|
10500
|
+
return scanCharacterEscape(
|
|
10501
|
+
/*atomEscape*/
|
|
10502
|
+
false
|
|
10503
|
+
);
|
|
10477
10504
|
}
|
|
10478
10505
|
} else if (ch === text2.charCodeAt(pos + 1)) {
|
|
10479
10506
|
switch (ch) {
|
|
@@ -10530,7 +10557,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10530
10557
|
if (scanCharacterClassEscape()) {
|
|
10531
10558
|
return "";
|
|
10532
10559
|
}
|
|
10533
|
-
return scanCharacterEscape(
|
|
10560
|
+
return scanCharacterEscape(
|
|
10561
|
+
/*atomEscape*/
|
|
10562
|
+
false
|
|
10563
|
+
);
|
|
10534
10564
|
}
|
|
10535
10565
|
} else {
|
|
10536
10566
|
return scanSourceCharacter();
|
|
@@ -10645,11 +10675,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10645
10675
|
}
|
|
10646
10676
|
});
|
|
10647
10677
|
forEach(decimalEscapes, (escape) => {
|
|
10648
|
-
if (escape.value > numberOfCapturingGroups) {
|
|
10678
|
+
if (!annexB && escape.value > numberOfCapturingGroups) {
|
|
10649
10679
|
if (numberOfCapturingGroups) {
|
|
10650
|
-
error(Diagnostics.
|
|
10680
|
+
error(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
|
|
10651
10681
|
} else {
|
|
10652
|
-
error(Diagnostics.
|
|
10682
|
+
error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
|
|
10653
10683
|
}
|
|
10654
10684
|
}
|
|
10655
10685
|
});
|
|
@@ -45252,6 +45282,7 @@ function createTypeChecker(host) {
|
|
|
45252
45282
|
var requestedExternalEmitHelperNames = /* @__PURE__ */ new Set();
|
|
45253
45283
|
var requestedExternalEmitHelpers;
|
|
45254
45284
|
var externalHelpersModule;
|
|
45285
|
+
var scanner;
|
|
45255
45286
|
var Symbol12 = objectAllocator.getSymbolConstructor();
|
|
45256
45287
|
var Type7 = objectAllocator.getTypeConstructor();
|
|
45257
45288
|
var Signature5 = objectAllocator.getSignatureConstructor();
|
|
@@ -50111,7 +50142,8 @@ function createTypeChecker(host) {
|
|
|
50111
50142
|
deepCloneOrReuseNode,
|
|
50112
50143
|
/*context*/
|
|
50113
50144
|
void 0,
|
|
50114
|
-
deepCloneOrReuseNodes
|
|
50145
|
+
deepCloneOrReuseNodes,
|
|
50146
|
+
deepCloneOrReuseNode
|
|
50115
50147
|
)), node);
|
|
50116
50148
|
}
|
|
50117
50149
|
function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
|
|
@@ -71090,6 +71122,53 @@ function createTypeChecker(host) {
|
|
|
71090
71122
|
return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
|
|
71091
71123
|
}
|
|
71092
71124
|
}
|
|
71125
|
+
function checkGrammarRegularExpressionLiteral(node) {
|
|
71126
|
+
const sourceFile = getSourceFileOfNode(node);
|
|
71127
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
71128
|
+
let lastError;
|
|
71129
|
+
scanner ?? (scanner = createScanner(
|
|
71130
|
+
99 /* ESNext */,
|
|
71131
|
+
/*skipTrivia*/
|
|
71132
|
+
true
|
|
71133
|
+
));
|
|
71134
|
+
scanner.setScriptTarget(sourceFile.languageVersion);
|
|
71135
|
+
scanner.setLanguageVariant(sourceFile.languageVariant);
|
|
71136
|
+
scanner.setOnError((message, length2, arg0) => {
|
|
71137
|
+
const start = scanner.getTokenEnd();
|
|
71138
|
+
if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
|
|
71139
|
+
const error2 = createDetachedDiagnostic(sourceFile.fileName, sourceFile.text, start, length2, message, arg0);
|
|
71140
|
+
addRelatedInfo(lastError, error2);
|
|
71141
|
+
} else if (!lastError || start !== lastError.start) {
|
|
71142
|
+
lastError = createFileDiagnostic(sourceFile, start, length2, message, arg0);
|
|
71143
|
+
diagnostics.add(lastError);
|
|
71144
|
+
}
|
|
71145
|
+
});
|
|
71146
|
+
scanner.setText(sourceFile.text, node.pos, node.end - node.pos);
|
|
71147
|
+
try {
|
|
71148
|
+
scanner.scan();
|
|
71149
|
+
Debug.assert(scanner.reScanSlashToken(
|
|
71150
|
+
/*reportErrors*/
|
|
71151
|
+
true
|
|
71152
|
+
) === 14 /* RegularExpressionLiteral */, "Expected scanner to rescan RegularExpressionLiteral");
|
|
71153
|
+
return !!lastError;
|
|
71154
|
+
} finally {
|
|
71155
|
+
scanner.setText("");
|
|
71156
|
+
scanner.setOnError(
|
|
71157
|
+
/*onError*/
|
|
71158
|
+
void 0
|
|
71159
|
+
);
|
|
71160
|
+
}
|
|
71161
|
+
}
|
|
71162
|
+
return false;
|
|
71163
|
+
}
|
|
71164
|
+
function checkRegularExpressionLiteral(node) {
|
|
71165
|
+
const nodeLinks2 = getNodeLinks(node);
|
|
71166
|
+
if (!(nodeLinks2.flags & 1 /* TypeChecked */)) {
|
|
71167
|
+
nodeLinks2.flags |= 1 /* TypeChecked */;
|
|
71168
|
+
addLazyDiagnostic(() => checkGrammarRegularExpressionLiteral(node));
|
|
71169
|
+
}
|
|
71170
|
+
return globalRegExpType;
|
|
71171
|
+
}
|
|
71093
71172
|
function checkSpreadExpression(node, checkMode) {
|
|
71094
71173
|
if (languageVersion < 2 /* SpreadElements */) {
|
|
71095
71174
|
checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
|
|
@@ -76993,7 +77072,7 @@ function createTypeChecker(host) {
|
|
|
76993
77072
|
parent = parent.parent;
|
|
76994
77073
|
}
|
|
76995
77074
|
if (operator === 56 /* AmpersandAmpersandToken */ || isIfStatement(parent)) {
|
|
76996
|
-
|
|
77075
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.left, leftType, isIfStatement(parent) ? parent.thenStatement : void 0);
|
|
76997
77076
|
}
|
|
76998
77077
|
checkTruthinessOfType(leftType, node.left);
|
|
76999
77078
|
}
|
|
@@ -77551,7 +77630,7 @@ function createTypeChecker(host) {
|
|
|
77551
77630
|
}
|
|
77552
77631
|
function checkConditionalExpression(node, checkMode) {
|
|
77553
77632
|
const type = checkTruthinessExpression(node.condition, checkMode);
|
|
77554
|
-
|
|
77633
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.condition, type, node.whenTrue);
|
|
77555
77634
|
const type1 = checkExpression(node.whenTrue, checkMode);
|
|
77556
77635
|
const type2 = checkExpression(node.whenFalse, checkMode);
|
|
77557
77636
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -78024,7 +78103,7 @@ function createTypeChecker(host) {
|
|
|
78024
78103
|
case 228 /* TemplateExpression */:
|
|
78025
78104
|
return checkTemplateExpression(node);
|
|
78026
78105
|
case 14 /* RegularExpressionLiteral */:
|
|
78027
|
-
return
|
|
78106
|
+
return checkRegularExpressionLiteral(node);
|
|
78028
78107
|
case 209 /* ArrayLiteralExpression */:
|
|
78029
78108
|
return checkArrayLiteral(node, checkMode, forceTuple);
|
|
78030
78109
|
case 210 /* ObjectLiteralExpression */:
|
|
@@ -80599,14 +80678,14 @@ function createTypeChecker(host) {
|
|
|
80599
80678
|
function checkIfStatement(node) {
|
|
80600
80679
|
checkGrammarStatementInAmbientContext(node);
|
|
80601
80680
|
const type = checkTruthinessExpression(node.expression);
|
|
80602
|
-
|
|
80681
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.expression, type, node.thenStatement);
|
|
80603
80682
|
checkSourceElement(node.thenStatement);
|
|
80604
80683
|
if (node.thenStatement.kind === 242 /* EmptyStatement */) {
|
|
80605
80684
|
error(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
80606
80685
|
}
|
|
80607
80686
|
checkSourceElement(node.elseStatement);
|
|
80608
80687
|
}
|
|
80609
|
-
function
|
|
80688
|
+
function checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(condExpr, condType, body) {
|
|
80610
80689
|
if (!strictNullChecks)
|
|
80611
80690
|
return;
|
|
80612
80691
|
bothHelper(condExpr, body);
|
|
@@ -80628,6 +80707,10 @@ function createTypeChecker(host) {
|
|
|
80628
80707
|
return;
|
|
80629
80708
|
}
|
|
80630
80709
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
80710
|
+
if (type.flags & 1024 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
80711
|
+
error(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
80712
|
+
return;
|
|
80713
|
+
}
|
|
80631
80714
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
80632
80715
|
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
80633
80716
|
return;
|
|
@@ -83073,7 +83156,7 @@ function createTypeChecker(host) {
|
|
|
83073
83156
|
if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83074
83157
|
return;
|
|
83075
83158
|
}
|
|
83076
|
-
if (!checkGrammarModifiers(node) &&
|
|
83159
|
+
if (!checkGrammarModifiers(node) && node.modifiers) {
|
|
83077
83160
|
grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
|
|
83078
83161
|
}
|
|
83079
83162
|
if (checkExternalImportOrExportDeclaration(node)) {
|
package/lib/typescript.js
CHANGED
|
@@ -2361,7 +2361,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2361
2361
|
|
|
2362
2362
|
// src/compiler/corePublic.ts
|
|
2363
2363
|
var versionMajorMinor = "5.5";
|
|
2364
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2364
|
+
var version = `${versionMajorMinor}.0-dev.20240425`;
|
|
2365
2365
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2366
2366
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2367
2367
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9813,8 +9813,8 @@ var Diagnostics = {
|
|
|
9813
9813
|
Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1530, 1 /* Error */, "Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v__1530", "Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
|
|
9814
9814
|
_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces: diag(1531, 1 /* Error */, "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1531", "'\\{0}' must be followed by a Unicode property value expression enclosed in braces."),
|
|
9815
9815
|
There_is_no_capturing_group_named_0_in_this_regular_expression: diag(1532, 1 /* Error */, "There_is_no_capturing_group_named_0_in_this_regular_expression_1532", "There is no capturing group named '{0}' in this regular expression."),
|
|
9816
|
-
|
|
9817
|
-
|
|
9816
|
+
This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1533, 1 /* Error */, "This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_r_1533", "This backreference refers to a group that does not exist. There are only {0} capturing groups in this regular expression."),
|
|
9817
|
+
This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups: diag(1534, 1 /* Error */, "This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups_1534", "This backreference is invalid because the containing regular expression contains no capturing groups."),
|
|
9818
9818
|
This_character_cannot_be_escaped_in_a_regular_expression: diag(1535, 1 /* Error */, "This_character_cannot_be_escaped_in_a_regular_expression_1535", "This character cannot be escaped in a regular expression."),
|
|
9819
9819
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
9820
9820
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
@@ -12643,7 +12643,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12643
12643
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12644
12644
|
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
12645
12645
|
const code = parseInt(text.substring(start2 + 1, pos), 8);
|
|
12646
|
-
|
|
12646
|
+
if (isRegularExpression !== "annex-b") {
|
|
12647
|
+
error2(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
|
|
12648
|
+
}
|
|
12647
12649
|
return String.fromCharCode(code);
|
|
12648
12650
|
}
|
|
12649
12651
|
return text.substring(start2, pos);
|
|
@@ -12674,7 +12676,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12674
12676
|
case 117 /* u */:
|
|
12675
12677
|
if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
12676
12678
|
pos -= 2;
|
|
12677
|
-
return scanExtendedUnicodeEscape(isRegularExpression || shouldEmitInvalidEscapeError);
|
|
12679
|
+
return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
|
|
12678
12680
|
}
|
|
12679
12681
|
for (; pos < start2 + 6; pos++) {
|
|
12680
12682
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
@@ -12724,7 +12726,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12724
12726
|
case 8233 /* paragraphSeparator */:
|
|
12725
12727
|
return "";
|
|
12726
12728
|
default:
|
|
12727
|
-
if (isRegularExpression && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
|
|
12729
|
+
if (isRegularExpression === true && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
|
|
12728
12730
|
error2(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2);
|
|
12729
12731
|
}
|
|
12730
12732
|
return String.fromCharCode(ch);
|
|
@@ -13419,7 +13421,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13419
13421
|
pos = tokenStart + 1;
|
|
13420
13422
|
return token = 64 /* EqualsToken */;
|
|
13421
13423
|
}
|
|
13422
|
-
function reScanSlashToken() {
|
|
13424
|
+
function reScanSlashToken(reportErrors2) {
|
|
13423
13425
|
if (token === 44 /* SlashToken */ || token === 69 /* SlashEqualsToken */) {
|
|
13424
13426
|
let p = tokenStart + 1;
|
|
13425
13427
|
let inEscape = false;
|
|
@@ -13458,38 +13460,54 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13458
13460
|
if (!isIdentifierPart(ch, languageVersion)) {
|
|
13459
13461
|
break;
|
|
13460
13462
|
}
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13463
|
+
if (reportErrors2) {
|
|
13464
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
13465
|
+
if (flag === void 0) {
|
|
13466
|
+
error2(Diagnostics.Unknown_regular_expression_flag, p, 1);
|
|
13467
|
+
} else if (regExpFlags & flag) {
|
|
13468
|
+
error2(Diagnostics.Duplicate_regular_expression_flag, p, 1);
|
|
13469
|
+
} else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
|
|
13470
|
+
error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
|
|
13471
|
+
} else {
|
|
13472
|
+
regExpFlags |= flag;
|
|
13473
|
+
const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
|
|
13474
|
+
if (languageVersion < availableFrom) {
|
|
13475
|
+
error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, getNameOfScriptTarget(availableFrom));
|
|
13476
|
+
}
|
|
13473
13477
|
}
|
|
13474
13478
|
}
|
|
13475
13479
|
p++;
|
|
13476
13480
|
}
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13481
|
+
if (reportErrors2) {
|
|
13482
|
+
pos = tokenStart + 1;
|
|
13483
|
+
const saveTokenPos = tokenStart;
|
|
13484
|
+
const saveTokenFlags = tokenFlags;
|
|
13485
|
+
scanRegularExpressionWorker(
|
|
13486
|
+
text,
|
|
13487
|
+
endOfBody,
|
|
13488
|
+
regExpFlags,
|
|
13489
|
+
isUnterminated,
|
|
13490
|
+
/*annexB*/
|
|
13491
|
+
true
|
|
13492
|
+
);
|
|
13493
|
+
if (!isUnterminated) {
|
|
13494
|
+
pos = p;
|
|
13495
|
+
}
|
|
13496
|
+
tokenStart = saveTokenPos;
|
|
13497
|
+
tokenFlags = saveTokenFlags;
|
|
13498
|
+
} else {
|
|
13482
13499
|
pos = p;
|
|
13483
13500
|
}
|
|
13484
|
-
tokenStart = saveTokenPos;
|
|
13485
|
-
tokenFlags = saveTokenFlags;
|
|
13486
13501
|
tokenValue = text.substring(tokenStart, pos);
|
|
13487
13502
|
token = 14 /* RegularExpressionLiteral */;
|
|
13488
13503
|
}
|
|
13489
13504
|
return token;
|
|
13490
|
-
function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated) {
|
|
13491
|
-
const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
13505
|
+
function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated, annexB) {
|
|
13492
13506
|
const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
|
|
13507
|
+
const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
13508
|
+
if (unicodeMode) {
|
|
13509
|
+
annexB = false;
|
|
13510
|
+
}
|
|
13493
13511
|
let mayContainStrings = false;
|
|
13494
13512
|
let numberOfCapturingGroups = 0;
|
|
13495
13513
|
const groupSpecifiers = /* @__PURE__ */ new Set();
|
|
@@ -13540,7 +13558,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13540
13558
|
case 61 /* equals */:
|
|
13541
13559
|
case 33 /* exclamation */:
|
|
13542
13560
|
pos++;
|
|
13543
|
-
isPreviousTermQuantifiable =
|
|
13561
|
+
isPreviousTermQuantifiable = annexB;
|
|
13544
13562
|
break;
|
|
13545
13563
|
case 60 /* lessThan */:
|
|
13546
13564
|
const groupNameStart = pos;
|
|
@@ -13719,7 +13737,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13719
13737
|
break;
|
|
13720
13738
|
}
|
|
13721
13739
|
default:
|
|
13722
|
-
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
|
|
13740
|
+
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
|
|
13741
|
+
/*atomEscape*/
|
|
13742
|
+
true
|
|
13743
|
+
));
|
|
13723
13744
|
break;
|
|
13724
13745
|
}
|
|
13725
13746
|
}
|
|
@@ -13734,7 +13755,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13734
13755
|
}
|
|
13735
13756
|
return false;
|
|
13736
13757
|
}
|
|
13737
|
-
function scanCharacterEscape() {
|
|
13758
|
+
function scanCharacterEscape(atomEscape) {
|
|
13738
13759
|
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
13739
13760
|
let ch = text2.charCodeAt(pos);
|
|
13740
13761
|
switch (ch) {
|
|
@@ -13747,6 +13768,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13747
13768
|
}
|
|
13748
13769
|
if (unicodeMode) {
|
|
13749
13770
|
error2(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
|
|
13771
|
+
} else if (atomEscape && annexB) {
|
|
13772
|
+
pos--;
|
|
13773
|
+
return "\\";
|
|
13750
13774
|
}
|
|
13751
13775
|
return String.fromCharCode(ch);
|
|
13752
13776
|
case 94 /* caret */:
|
|
@@ -13776,7 +13800,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13776
13800
|
/*shouldEmitInvalidEscapeError*/
|
|
13777
13801
|
unicodeMode,
|
|
13778
13802
|
/*isRegularExpression*/
|
|
13779
|
-
true
|
|
13803
|
+
annexB ? "annex-b" : true
|
|
13780
13804
|
);
|
|
13781
13805
|
}
|
|
13782
13806
|
}
|
|
@@ -13816,12 +13840,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13816
13840
|
if (isClassContentExit(ch2)) {
|
|
13817
13841
|
return;
|
|
13818
13842
|
}
|
|
13819
|
-
if (!minCharacter) {
|
|
13843
|
+
if (!minCharacter && !annexB) {
|
|
13820
13844
|
error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
|
|
13821
13845
|
}
|
|
13822
13846
|
const maxStart = pos;
|
|
13823
13847
|
const maxCharacter = scanClassAtom();
|
|
13824
|
-
if (!maxCharacter) {
|
|
13848
|
+
if (!maxCharacter && !annexB) {
|
|
13825
13849
|
error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
|
|
13826
13850
|
continue;
|
|
13827
13851
|
}
|
|
@@ -14104,7 +14128,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
14104
14128
|
pos++;
|
|
14105
14129
|
return String.fromCharCode(ch2);
|
|
14106
14130
|
default:
|
|
14107
|
-
return scanCharacterEscape(
|
|
14131
|
+
return scanCharacterEscape(
|
|
14132
|
+
/*atomEscape*/
|
|
14133
|
+
false
|
|
14134
|
+
);
|
|
14108
14135
|
}
|
|
14109
14136
|
} else if (ch === text2.charCodeAt(pos + 1)) {
|
|
14110
14137
|
switch (ch) {
|
|
@@ -14161,7 +14188,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
14161
14188
|
if (scanCharacterClassEscape()) {
|
|
14162
14189
|
return "";
|
|
14163
14190
|
}
|
|
14164
|
-
return scanCharacterEscape(
|
|
14191
|
+
return scanCharacterEscape(
|
|
14192
|
+
/*atomEscape*/
|
|
14193
|
+
false
|
|
14194
|
+
);
|
|
14165
14195
|
}
|
|
14166
14196
|
} else {
|
|
14167
14197
|
return scanSourceCharacter();
|
|
@@ -14276,11 +14306,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
14276
14306
|
}
|
|
14277
14307
|
});
|
|
14278
14308
|
forEach(decimalEscapes, (escape) => {
|
|
14279
|
-
if (escape.value > numberOfCapturingGroups) {
|
|
14309
|
+
if (!annexB && escape.value > numberOfCapturingGroups) {
|
|
14280
14310
|
if (numberOfCapturingGroups) {
|
|
14281
|
-
error2(Diagnostics.
|
|
14311
|
+
error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
|
|
14282
14312
|
} else {
|
|
14283
|
-
error2(Diagnostics.
|
|
14313
|
+
error2(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
|
|
14284
14314
|
}
|
|
14285
14315
|
}
|
|
14286
14316
|
});
|
|
@@ -50077,6 +50107,7 @@ function createTypeChecker(host) {
|
|
|
50077
50107
|
var requestedExternalEmitHelperNames = /* @__PURE__ */ new Set();
|
|
50078
50108
|
var requestedExternalEmitHelpers;
|
|
50079
50109
|
var externalHelpersModule;
|
|
50110
|
+
var scanner2;
|
|
50080
50111
|
var Symbol47 = objectAllocator.getSymbolConstructor();
|
|
50081
50112
|
var Type28 = objectAllocator.getTypeConstructor();
|
|
50082
50113
|
var Signature14 = objectAllocator.getSignatureConstructor();
|
|
@@ -54936,7 +54967,8 @@ function createTypeChecker(host) {
|
|
|
54936
54967
|
deepCloneOrReuseNode,
|
|
54937
54968
|
/*context*/
|
|
54938
54969
|
void 0,
|
|
54939
|
-
deepCloneOrReuseNodes
|
|
54970
|
+
deepCloneOrReuseNodes,
|
|
54971
|
+
deepCloneOrReuseNode
|
|
54940
54972
|
)), node);
|
|
54941
54973
|
}
|
|
54942
54974
|
function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
|
|
@@ -75915,6 +75947,53 @@ function createTypeChecker(host) {
|
|
|
75915
75947
|
return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
|
|
75916
75948
|
}
|
|
75917
75949
|
}
|
|
75950
|
+
function checkGrammarRegularExpressionLiteral(node) {
|
|
75951
|
+
const sourceFile = getSourceFileOfNode(node);
|
|
75952
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
75953
|
+
let lastError;
|
|
75954
|
+
scanner2 ?? (scanner2 = createScanner(
|
|
75955
|
+
99 /* ESNext */,
|
|
75956
|
+
/*skipTrivia*/
|
|
75957
|
+
true
|
|
75958
|
+
));
|
|
75959
|
+
scanner2.setScriptTarget(sourceFile.languageVersion);
|
|
75960
|
+
scanner2.setLanguageVariant(sourceFile.languageVariant);
|
|
75961
|
+
scanner2.setOnError((message, length2, arg0) => {
|
|
75962
|
+
const start = scanner2.getTokenEnd();
|
|
75963
|
+
if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
|
|
75964
|
+
const error3 = createDetachedDiagnostic(sourceFile.fileName, sourceFile.text, start, length2, message, arg0);
|
|
75965
|
+
addRelatedInfo(lastError, error3);
|
|
75966
|
+
} else if (!lastError || start !== lastError.start) {
|
|
75967
|
+
lastError = createFileDiagnostic(sourceFile, start, length2, message, arg0);
|
|
75968
|
+
diagnostics.add(lastError);
|
|
75969
|
+
}
|
|
75970
|
+
});
|
|
75971
|
+
scanner2.setText(sourceFile.text, node.pos, node.end - node.pos);
|
|
75972
|
+
try {
|
|
75973
|
+
scanner2.scan();
|
|
75974
|
+
Debug.assert(scanner2.reScanSlashToken(
|
|
75975
|
+
/*reportErrors*/
|
|
75976
|
+
true
|
|
75977
|
+
) === 14 /* RegularExpressionLiteral */, "Expected scanner to rescan RegularExpressionLiteral");
|
|
75978
|
+
return !!lastError;
|
|
75979
|
+
} finally {
|
|
75980
|
+
scanner2.setText("");
|
|
75981
|
+
scanner2.setOnError(
|
|
75982
|
+
/*onError*/
|
|
75983
|
+
void 0
|
|
75984
|
+
);
|
|
75985
|
+
}
|
|
75986
|
+
}
|
|
75987
|
+
return false;
|
|
75988
|
+
}
|
|
75989
|
+
function checkRegularExpressionLiteral(node) {
|
|
75990
|
+
const nodeLinks2 = getNodeLinks(node);
|
|
75991
|
+
if (!(nodeLinks2.flags & 1 /* TypeChecked */)) {
|
|
75992
|
+
nodeLinks2.flags |= 1 /* TypeChecked */;
|
|
75993
|
+
addLazyDiagnostic(() => checkGrammarRegularExpressionLiteral(node));
|
|
75994
|
+
}
|
|
75995
|
+
return globalRegExpType;
|
|
75996
|
+
}
|
|
75918
75997
|
function checkSpreadExpression(node, checkMode) {
|
|
75919
75998
|
if (languageVersion < 2 /* SpreadElements */) {
|
|
75920
75999
|
checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
|
|
@@ -81818,7 +81897,7 @@ function createTypeChecker(host) {
|
|
|
81818
81897
|
parent2 = parent2.parent;
|
|
81819
81898
|
}
|
|
81820
81899
|
if (operator === 56 /* AmpersandAmpersandToken */ || isIfStatement(parent2)) {
|
|
81821
|
-
|
|
81900
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.left, leftType, isIfStatement(parent2) ? parent2.thenStatement : void 0);
|
|
81822
81901
|
}
|
|
81823
81902
|
checkTruthinessOfType(leftType, node.left);
|
|
81824
81903
|
}
|
|
@@ -82376,7 +82455,7 @@ function createTypeChecker(host) {
|
|
|
82376
82455
|
}
|
|
82377
82456
|
function checkConditionalExpression(node, checkMode) {
|
|
82378
82457
|
const type = checkTruthinessExpression(node.condition, checkMode);
|
|
82379
|
-
|
|
82458
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.condition, type, node.whenTrue);
|
|
82380
82459
|
const type1 = checkExpression(node.whenTrue, checkMode);
|
|
82381
82460
|
const type2 = checkExpression(node.whenFalse, checkMode);
|
|
82382
82461
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -82849,7 +82928,7 @@ function createTypeChecker(host) {
|
|
|
82849
82928
|
case 228 /* TemplateExpression */:
|
|
82850
82929
|
return checkTemplateExpression(node);
|
|
82851
82930
|
case 14 /* RegularExpressionLiteral */:
|
|
82852
|
-
return
|
|
82931
|
+
return checkRegularExpressionLiteral(node);
|
|
82853
82932
|
case 209 /* ArrayLiteralExpression */:
|
|
82854
82933
|
return checkArrayLiteral(node, checkMode, forceTuple);
|
|
82855
82934
|
case 210 /* ObjectLiteralExpression */:
|
|
@@ -85424,14 +85503,14 @@ function createTypeChecker(host) {
|
|
|
85424
85503
|
function checkIfStatement(node) {
|
|
85425
85504
|
checkGrammarStatementInAmbientContext(node);
|
|
85426
85505
|
const type = checkTruthinessExpression(node.expression);
|
|
85427
|
-
|
|
85506
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.expression, type, node.thenStatement);
|
|
85428
85507
|
checkSourceElement(node.thenStatement);
|
|
85429
85508
|
if (node.thenStatement.kind === 242 /* EmptyStatement */) {
|
|
85430
85509
|
error2(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
85431
85510
|
}
|
|
85432
85511
|
checkSourceElement(node.elseStatement);
|
|
85433
85512
|
}
|
|
85434
|
-
function
|
|
85513
|
+
function checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(condExpr, condType, body) {
|
|
85435
85514
|
if (!strictNullChecks)
|
|
85436
85515
|
return;
|
|
85437
85516
|
bothHelper(condExpr, body);
|
|
@@ -85453,6 +85532,10 @@ function createTypeChecker(host) {
|
|
|
85453
85532
|
return;
|
|
85454
85533
|
}
|
|
85455
85534
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
85535
|
+
if (type.flags & 1024 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
85536
|
+
error2(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
85537
|
+
return;
|
|
85538
|
+
}
|
|
85456
85539
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
85457
85540
|
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
85458
85541
|
return;
|
|
@@ -87898,7 +87981,7 @@ function createTypeChecker(host) {
|
|
|
87898
87981
|
if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
87899
87982
|
return;
|
|
87900
87983
|
}
|
|
87901
|
-
if (!checkGrammarModifiers(node) &&
|
|
87984
|
+
if (!checkGrammarModifiers(node) && node.modifiers) {
|
|
87902
87985
|
grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
|
|
87903
87986
|
}
|
|
87904
87987
|
if (checkExternalImportOrExportDeclaration(node)) {
|
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.5.0-dev.
|
|
5
|
+
"version": "5.5.0-dev.20240425",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"node": "20.1.0",
|
|
111
111
|
"npm": "8.19.4"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "9504b7576a6489a3d5149db451b6ec8f772d67d4"
|
|
114
114
|
}
|