@typescript-deploys/pr-build 5.5.0-pr-58361-3 → 5.5.0-pr-58380-2
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 +955 -908
- package/lib/typescript.js +2073 -1122
- package/package.json +1 -1
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-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240430`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -6203,7 +6203,7 @@ var Diagnostics = {
|
|
|
6203
6203
|
Range_out_of_order_in_character_class: diag(1517, 1 /* Error */, "Range_out_of_order_in_character_class_1517", "Range out of order in character class."),
|
|
6204
6204
|
Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class: diag(1518, 1 /* Error */, "Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_characte_1518", "Anything that would possibly match more than a single character is invalid inside a negated character class."),
|
|
6205
6205
|
Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead: diag(1519, 1 /* Error */, "Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead_1519", "Operators must not be mixed within a character class. Wrap it in a nested class instead."),
|
|
6206
|
-
|
|
6206
|
+
Expected_a_class_set_operand: diag(1520, 1 /* Error */, "Expected_a_class_set_operand_1520", "Expected a class set operand."),
|
|
6207
6207
|
q_must_be_followed_by_string_alternatives_enclosed_in_braces: diag(1521, 1 /* Error */, "q_must_be_followed_by_string_alternatives_enclosed_in_braces_1521", "'\\q' must be followed by string alternatives enclosed in braces."),
|
|
6208
6208
|
A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash: diag(1522, 1 /* Error */, "A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backs_1522", "A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?"),
|
|
6209
6209
|
Expected_a_Unicode_property_name: diag(1523, 1 /* Error */, "Expected_a_Unicode_property_name_1523", "Expected a Unicode property name."),
|
|
@@ -7716,6 +7716,16 @@ var Diagnostics = {
|
|
|
7716
7716
|
Export_0_from_module_1: diag(90059, 3 /* Message */, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
7717
7717
|
Export_all_referenced_locals: diag(90060, 3 /* Message */, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
7718
7718
|
Update_modifiers_of_0: diag(90061, 3 /* Message */, "Update_modifiers_of_0_90061", "Update modifiers of '{0}'"),
|
|
7719
|
+
Add_annotation_of_type_0: diag(90062, 3 /* Message */, "Add_annotation_of_type_0_90062", "Add annotation of type '{0}'"),
|
|
7720
|
+
Add_return_type_0: diag(90063, 3 /* Message */, "Add_return_type_0_90063", "Add return type '{0}'"),
|
|
7721
|
+
Extract_base_class_to_variable: diag(90064, 3 /* Message */, "Extract_base_class_to_variable_90064", "Extract base class to variable"),
|
|
7722
|
+
Extract_default_export_to_variable: diag(90065, 3 /* Message */, "Extract_default_export_to_variable_90065", "Extract default export to variable"),
|
|
7723
|
+
Extract_binding_expressions_to_variable: diag(90066, 3 /* Message */, "Extract_binding_expressions_to_variable_90066", "Extract binding expressions to variable"),
|
|
7724
|
+
Add_all_missing_type_annotations: diag(90067, 3 /* Message */, "Add_all_missing_type_annotations_90067", "Add all missing type annotations"),
|
|
7725
|
+
Add_satisfies_and_an_inline_type_assertion_with_0: diag(90068, 3 /* Message */, "Add_satisfies_and_an_inline_type_assertion_with_0_90068", "Add satisfies and an inline type assertion with '{0}'"),
|
|
7726
|
+
Extract_to_variable_and_replace_with_0_as_typeof_0: diag(90069, 3 /* Message */, "Extract_to_variable_and_replace_with_0_as_typeof_0_90069", "Extract to variable and replace with '{0} as typeof {0}'"),
|
|
7727
|
+
Mark_array_literal_as_const: diag(90070, 3 /* Message */, "Mark_array_literal_as_const_90070", "Mark array literal as const"),
|
|
7728
|
+
Annotate_types_of_properties_expando_function_in_a_namespace: diag(90071, 3 /* Message */, "Annotate_types_of_properties_expando_function_in_a_namespace_90071", "Annotate types of properties expando function in a namespace"),
|
|
7719
7729
|
Convert_function_to_an_ES2015_class: diag(95001, 3 /* Message */, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
7720
7730
|
Convert_0_to_1_in_0: diag(95003, 3 /* Message */, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
7721
7731
|
Extract_to_0_in_1: diag(95004, 3 /* Message */, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -8689,6 +8699,18 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8689
8699
|
});
|
|
8690
8700
|
}
|
|
8691
8701
|
return scanner;
|
|
8702
|
+
function codePointUnchecked(pos2) {
|
|
8703
|
+
return codePointAt(text, pos2);
|
|
8704
|
+
}
|
|
8705
|
+
function codePointChecked(pos2) {
|
|
8706
|
+
return pos2 >= 0 && pos2 < end ? codePointUnchecked(pos2) : -1 /* EOF */;
|
|
8707
|
+
}
|
|
8708
|
+
function charCodeUnchecked(pos2) {
|
|
8709
|
+
return text.charCodeAt(pos2);
|
|
8710
|
+
}
|
|
8711
|
+
function charCodeChecked(pos2) {
|
|
8712
|
+
return pos2 >= 0 && pos2 < end ? charCodeUnchecked(pos2) : -1 /* EOF */;
|
|
8713
|
+
}
|
|
8692
8714
|
function error(message, errPos = pos, length3, arg0) {
|
|
8693
8715
|
if (onError) {
|
|
8694
8716
|
const oldPos = pos;
|
|
@@ -8703,7 +8725,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8703
8725
|
let isPreviousTokenSeparator = false;
|
|
8704
8726
|
let result = "";
|
|
8705
8727
|
while (true) {
|
|
8706
|
-
const ch =
|
|
8728
|
+
const ch = charCodeUnchecked(pos);
|
|
8707
8729
|
if (ch === 95 /* _ */) {
|
|
8708
8730
|
tokenFlags |= 512 /* ContainsSeparator */;
|
|
8709
8731
|
if (allowSeparator) {
|
|
@@ -8730,7 +8752,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8730
8752
|
}
|
|
8731
8753
|
break;
|
|
8732
8754
|
}
|
|
8733
|
-
if (
|
|
8755
|
+
if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
|
|
8734
8756
|
tokenFlags |= 16384 /* ContainsInvalidSeparator */;
|
|
8735
8757
|
error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
8736
8758
|
}
|
|
@@ -8739,9 +8761,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8739
8761
|
function scanNumber() {
|
|
8740
8762
|
let start2 = pos;
|
|
8741
8763
|
let mainFragment;
|
|
8742
|
-
if (
|
|
8764
|
+
if (charCodeUnchecked(pos) === 48 /* _0 */) {
|
|
8743
8765
|
pos++;
|
|
8744
|
-
if (
|
|
8766
|
+
if (charCodeUnchecked(pos) === 95 /* _ */) {
|
|
8745
8767
|
tokenFlags |= 512 /* ContainsSeparator */ | 16384 /* ContainsInvalidSeparator */;
|
|
8746
8768
|
error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
8747
8769
|
pos--;
|
|
@@ -8766,15 +8788,15 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8766
8788
|
}
|
|
8767
8789
|
let decimalFragment;
|
|
8768
8790
|
let scientificFragment;
|
|
8769
|
-
if (
|
|
8791
|
+
if (charCodeUnchecked(pos) === 46 /* dot */) {
|
|
8770
8792
|
pos++;
|
|
8771
8793
|
decimalFragment = scanNumberFragment();
|
|
8772
8794
|
}
|
|
8773
8795
|
let end2 = pos;
|
|
8774
|
-
if (
|
|
8796
|
+
if (charCodeUnchecked(pos) === 69 /* E */ || charCodeUnchecked(pos) === 101 /* e */) {
|
|
8775
8797
|
pos++;
|
|
8776
8798
|
tokenFlags |= 16 /* Scientific */;
|
|
8777
|
-
if (
|
|
8799
|
+
if (charCodeUnchecked(pos) === 43 /* plus */ || charCodeUnchecked(pos) === 45 /* minus */)
|
|
8778
8800
|
pos++;
|
|
8779
8801
|
const preNumericPart = pos;
|
|
8780
8802
|
const finalFragment = scanNumberFragment();
|
|
@@ -8814,7 +8836,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8814
8836
|
}
|
|
8815
8837
|
}
|
|
8816
8838
|
function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
|
|
8817
|
-
if (!isIdentifierStart(
|
|
8839
|
+
if (!isIdentifierStart(codePointUnchecked(pos), languageVersion)) {
|
|
8818
8840
|
return;
|
|
8819
8841
|
}
|
|
8820
8842
|
const identifierStart = pos;
|
|
@@ -8833,8 +8855,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8833
8855
|
function scanDigits() {
|
|
8834
8856
|
const start2 = pos;
|
|
8835
8857
|
let isOctal = true;
|
|
8836
|
-
while (isDigit(
|
|
8837
|
-
if (!isOctalDigit(
|
|
8858
|
+
while (isDigit(charCodeChecked(pos))) {
|
|
8859
|
+
if (!isOctalDigit(charCodeUnchecked(pos))) {
|
|
8838
8860
|
isOctal = false;
|
|
8839
8861
|
}
|
|
8840
8862
|
pos++;
|
|
@@ -8866,7 +8888,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8866
8888
|
let allowSeparator = false;
|
|
8867
8889
|
let isPreviousTokenSeparator = false;
|
|
8868
8890
|
while (valueChars.length < minCount || scanAsManyAsPossible) {
|
|
8869
|
-
let ch =
|
|
8891
|
+
let ch = charCodeUnchecked(pos);
|
|
8870
8892
|
if (canHaveSeparators && ch === 95 /* _ */) {
|
|
8871
8893
|
tokenFlags |= 512 /* ContainsSeparator */;
|
|
8872
8894
|
if (allowSeparator) {
|
|
@@ -8893,13 +8915,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8893
8915
|
if (valueChars.length < minCount) {
|
|
8894
8916
|
valueChars = [];
|
|
8895
8917
|
}
|
|
8896
|
-
if (
|
|
8918
|
+
if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
|
|
8897
8919
|
error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
8898
8920
|
}
|
|
8899
8921
|
return String.fromCharCode(...valueChars);
|
|
8900
8922
|
}
|
|
8901
8923
|
function scanString(jsxAttributeString = false) {
|
|
8902
|
-
const quote =
|
|
8924
|
+
const quote = charCodeUnchecked(pos);
|
|
8903
8925
|
pos++;
|
|
8904
8926
|
let result = "";
|
|
8905
8927
|
let start2 = pos;
|
|
@@ -8910,7 +8932,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8910
8932
|
error(Diagnostics.Unterminated_string_literal);
|
|
8911
8933
|
break;
|
|
8912
8934
|
}
|
|
8913
|
-
const ch =
|
|
8935
|
+
const ch = charCodeUnchecked(pos);
|
|
8914
8936
|
if (ch === quote) {
|
|
8915
8937
|
result += text.substring(start2, pos);
|
|
8916
8938
|
pos++;
|
|
@@ -8938,7 +8960,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8938
8960
|
return result;
|
|
8939
8961
|
}
|
|
8940
8962
|
function scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError) {
|
|
8941
|
-
const startedWithBacktick =
|
|
8963
|
+
const startedWithBacktick = charCodeUnchecked(pos) === 96 /* backtick */;
|
|
8942
8964
|
pos++;
|
|
8943
8965
|
let start2 = pos;
|
|
8944
8966
|
let contents = "";
|
|
@@ -8951,14 +8973,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8951
8973
|
resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
|
|
8952
8974
|
break;
|
|
8953
8975
|
}
|
|
8954
|
-
const currChar =
|
|
8976
|
+
const currChar = charCodeUnchecked(pos);
|
|
8955
8977
|
if (currChar === 96 /* backtick */) {
|
|
8956
8978
|
contents += text.substring(start2, pos);
|
|
8957
8979
|
pos++;
|
|
8958
8980
|
resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
|
|
8959
8981
|
break;
|
|
8960
8982
|
}
|
|
8961
|
-
if (currChar === 36 /* $ */ && pos + 1 < end &&
|
|
8983
|
+
if (currChar === 36 /* $ */ && pos + 1 < end && charCodeUnchecked(pos + 1) === 123 /* openBrace */) {
|
|
8962
8984
|
contents += text.substring(start2, pos);
|
|
8963
8985
|
pos += 2;
|
|
8964
8986
|
resultingToken = startedWithBacktick ? 16 /* TemplateHead */ : 17 /* TemplateMiddle */;
|
|
@@ -8977,7 +8999,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8977
8999
|
if (currChar === 13 /* carriageReturn */) {
|
|
8978
9000
|
contents += text.substring(start2, pos);
|
|
8979
9001
|
pos++;
|
|
8980
|
-
if (pos < end &&
|
|
9002
|
+
if (pos < end && charCodeUnchecked(pos) === 10 /* lineFeed */) {
|
|
8981
9003
|
pos++;
|
|
8982
9004
|
}
|
|
8983
9005
|
contents += "\n";
|
|
@@ -8997,24 +9019,24 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8997
9019
|
error(Diagnostics.Unexpected_end_of_text);
|
|
8998
9020
|
return "";
|
|
8999
9021
|
}
|
|
9000
|
-
const ch =
|
|
9022
|
+
const ch = charCodeUnchecked(pos);
|
|
9001
9023
|
pos++;
|
|
9002
9024
|
switch (ch) {
|
|
9003
9025
|
case 48 /* _0 */:
|
|
9004
|
-
if (pos >= end || !isDigit(
|
|
9026
|
+
if (pos >= end || !isDigit(charCodeUnchecked(pos))) {
|
|
9005
9027
|
return "\0";
|
|
9006
9028
|
}
|
|
9007
9029
|
case 49 /* _1 */:
|
|
9008
9030
|
case 50 /* _2 */:
|
|
9009
9031
|
case 51 /* _3 */:
|
|
9010
|
-
if (pos < end && isOctalDigit(
|
|
9032
|
+
if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
|
|
9011
9033
|
pos++;
|
|
9012
9034
|
}
|
|
9013
9035
|
case 52 /* _4 */:
|
|
9014
9036
|
case 53 /* _5 */:
|
|
9015
9037
|
case 54 /* _6 */:
|
|
9016
9038
|
case 55 /* _7 */:
|
|
9017
|
-
if (pos < end && isOctalDigit(
|
|
9039
|
+
if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
|
|
9018
9040
|
pos++;
|
|
9019
9041
|
}
|
|
9020
9042
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
@@ -9051,12 +9073,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9051
9073
|
case 34 /* doubleQuote */:
|
|
9052
9074
|
return '"';
|
|
9053
9075
|
case 117 /* u */:
|
|
9054
|
-
if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end &&
|
|
9076
|
+
if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
|
|
9055
9077
|
pos -= 2;
|
|
9056
9078
|
return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
|
|
9057
9079
|
}
|
|
9058
9080
|
for (; pos < start2 + 6; pos++) {
|
|
9059
|
-
if (!(pos < end && isHexDigit(
|
|
9081
|
+
if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
|
|
9060
9082
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
9061
9083
|
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
9062
9084
|
error(Diagnostics.Hexadecimal_digit_expected);
|
|
@@ -9067,11 +9089,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9067
9089
|
tokenFlags |= 1024 /* UnicodeEscape */;
|
|
9068
9090
|
const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
|
|
9069
9091
|
const escapedValueString = String.fromCharCode(escapedValue);
|
|
9070
|
-
if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" &&
|
|
9092
|
+
if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
|
|
9071
9093
|
const nextStart = pos;
|
|
9072
9094
|
let nextPos = pos + 2;
|
|
9073
9095
|
for (; nextPos < nextStart + 6; nextPos++) {
|
|
9074
|
-
if (!isHexDigit(
|
|
9096
|
+
if (!isHexDigit(charCodeUnchecked(pos))) {
|
|
9075
9097
|
return escapedValueString;
|
|
9076
9098
|
}
|
|
9077
9099
|
}
|
|
@@ -9084,7 +9106,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9084
9106
|
return escapedValueString;
|
|
9085
9107
|
case 120 /* x */:
|
|
9086
9108
|
for (; pos < start2 + 4; pos++) {
|
|
9087
|
-
if (!(pos < end && isHexDigit(
|
|
9109
|
+
if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
|
|
9088
9110
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
9089
9111
|
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
9090
9112
|
error(Diagnostics.Hexadecimal_digit_expected);
|
|
@@ -9095,7 +9117,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9095
9117
|
tokenFlags |= 4096 /* HexEscape */;
|
|
9096
9118
|
return String.fromCharCode(parseInt(text.substring(start2 + 2, pos), 16));
|
|
9097
9119
|
case 13 /* carriageReturn */:
|
|
9098
|
-
if (pos < end &&
|
|
9120
|
+
if (pos < end && charCodeUnchecked(pos) === 10 /* lineFeed */) {
|
|
9099
9121
|
pos++;
|
|
9100
9122
|
}
|
|
9101
9123
|
case 10 /* lineFeed */:
|
|
@@ -9136,7 +9158,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9136
9158
|
error(Diagnostics.Unexpected_end_of_text);
|
|
9137
9159
|
}
|
|
9138
9160
|
isInvalidExtendedEscape = true;
|
|
9139
|
-
} else if (
|
|
9161
|
+
} else if (charCodeUnchecked(pos) === 125 /* closeBrace */) {
|
|
9140
9162
|
pos++;
|
|
9141
9163
|
} else {
|
|
9142
9164
|
if (shouldEmitInvalidEscapeError) {
|
|
@@ -9152,7 +9174,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9152
9174
|
return utf16EncodeAsString(escapedValue);
|
|
9153
9175
|
}
|
|
9154
9176
|
function peekUnicodeEscape() {
|
|
9155
|
-
if (pos + 5 < end &&
|
|
9177
|
+
if (pos + 5 < end && charCodeUnchecked(pos + 1) === 117 /* u */) {
|
|
9156
9178
|
const start2 = pos;
|
|
9157
9179
|
pos += 2;
|
|
9158
9180
|
const value = scanExactNumberOfHexDigits(
|
|
@@ -9166,7 +9188,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9166
9188
|
return -1;
|
|
9167
9189
|
}
|
|
9168
9190
|
function peekExtendedUnicodeEscape() {
|
|
9169
|
-
if (
|
|
9191
|
+
if (codePointUnchecked(pos + 1) === 117 /* u */ && codePointUnchecked(pos + 2) === 123 /* openBrace */) {
|
|
9170
9192
|
const start2 = pos;
|
|
9171
9193
|
pos += 3;
|
|
9172
9194
|
const escapedValueString = scanMinimumNumberOfHexDigits(
|
|
@@ -9184,7 +9206,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9184
9206
|
let result = "";
|
|
9185
9207
|
let start2 = pos;
|
|
9186
9208
|
while (pos < end) {
|
|
9187
|
-
let ch =
|
|
9209
|
+
let ch = codePointUnchecked(pos);
|
|
9188
9210
|
if (isIdentifierPart(ch, languageVersion)) {
|
|
9189
9211
|
pos += charSize(ch);
|
|
9190
9212
|
} else if (ch === 92 /* backslash */) {
|
|
@@ -9231,7 +9253,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9231
9253
|
let separatorAllowed = false;
|
|
9232
9254
|
let isPreviousTokenSeparator = false;
|
|
9233
9255
|
while (true) {
|
|
9234
|
-
const ch =
|
|
9256
|
+
const ch = charCodeUnchecked(pos);
|
|
9235
9257
|
if (ch === 95 /* _ */) {
|
|
9236
9258
|
tokenFlags |= 512 /* ContainsSeparator */;
|
|
9237
9259
|
if (separatorAllowed) {
|
|
@@ -9253,13 +9275,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9253
9275
|
pos++;
|
|
9254
9276
|
isPreviousTokenSeparator = false;
|
|
9255
9277
|
}
|
|
9256
|
-
if (
|
|
9278
|
+
if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
|
|
9257
9279
|
error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
9258
9280
|
}
|
|
9259
9281
|
return value;
|
|
9260
9282
|
}
|
|
9261
9283
|
function checkBigIntSuffix() {
|
|
9262
|
-
if (
|
|
9284
|
+
if (charCodeUnchecked(pos) === 110 /* n */) {
|
|
9263
9285
|
tokenValue += "n";
|
|
9264
9286
|
if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) {
|
|
9265
9287
|
tokenValue = parsePseudoBigInt(tokenValue) + "n";
|
|
@@ -9281,7 +9303,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9281
9303
|
if (pos >= end) {
|
|
9282
9304
|
return token = 1 /* EndOfFileToken */;
|
|
9283
9305
|
}
|
|
9284
|
-
const ch =
|
|
9306
|
+
const ch = codePointUnchecked(pos);
|
|
9285
9307
|
if (pos === 0) {
|
|
9286
9308
|
if (ch === 35 /* hash */ && isShebangTrivia(text, pos)) {
|
|
9287
9309
|
pos = scanShebangTrivia(text, pos);
|
|
@@ -9300,7 +9322,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9300
9322
|
pos++;
|
|
9301
9323
|
continue;
|
|
9302
9324
|
} else {
|
|
9303
|
-
if (ch === 13 /* carriageReturn */ && pos + 1 < end &&
|
|
9325
|
+
if (ch === 13 /* carriageReturn */ && pos + 1 < end && charCodeUnchecked(pos + 1) === 10 /* lineFeed */) {
|
|
9304
9326
|
pos += 2;
|
|
9305
9327
|
} else {
|
|
9306
9328
|
pos++;
|
|
@@ -9333,14 +9355,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9333
9355
|
pos++;
|
|
9334
9356
|
continue;
|
|
9335
9357
|
} else {
|
|
9336
|
-
while (pos < end && isWhiteSpaceSingleLine(
|
|
9358
|
+
while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
|
|
9337
9359
|
pos++;
|
|
9338
9360
|
}
|
|
9339
9361
|
return token = 5 /* WhitespaceTrivia */;
|
|
9340
9362
|
}
|
|
9341
9363
|
case 33 /* exclamation */:
|
|
9342
|
-
if (
|
|
9343
|
-
if (
|
|
9364
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9365
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9344
9366
|
return pos += 3, token = 38 /* ExclamationEqualsEqualsToken */;
|
|
9345
9367
|
}
|
|
9346
9368
|
return pos += 2, token = 36 /* ExclamationEqualsToken */;
|
|
@@ -9357,19 +9379,19 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9357
9379
|
false
|
|
9358
9380
|
);
|
|
9359
9381
|
case 37 /* percent */:
|
|
9360
|
-
if (
|
|
9382
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9361
9383
|
return pos += 2, token = 70 /* PercentEqualsToken */;
|
|
9362
9384
|
}
|
|
9363
9385
|
pos++;
|
|
9364
9386
|
return token = 45 /* PercentToken */;
|
|
9365
9387
|
case 38 /* ampersand */:
|
|
9366
|
-
if (
|
|
9367
|
-
if (
|
|
9388
|
+
if (charCodeUnchecked(pos + 1) === 38 /* ampersand */) {
|
|
9389
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9368
9390
|
return pos += 3, token = 77 /* AmpersandAmpersandEqualsToken */;
|
|
9369
9391
|
}
|
|
9370
9392
|
return pos += 2, token = 56 /* AmpersandAmpersandToken */;
|
|
9371
9393
|
}
|
|
9372
|
-
if (
|
|
9394
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9373
9395
|
return pos += 2, token = 74 /* AmpersandEqualsToken */;
|
|
9374
9396
|
}
|
|
9375
9397
|
pos++;
|
|
@@ -9381,11 +9403,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9381
9403
|
pos++;
|
|
9382
9404
|
return token = 22 /* CloseParenToken */;
|
|
9383
9405
|
case 42 /* asterisk */:
|
|
9384
|
-
if (
|
|
9406
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9385
9407
|
return pos += 2, token = 67 /* AsteriskEqualsToken */;
|
|
9386
9408
|
}
|
|
9387
|
-
if (
|
|
9388
|
-
if (
|
|
9409
|
+
if (charCodeUnchecked(pos + 1) === 42 /* asterisk */) {
|
|
9410
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9389
9411
|
return pos += 3, token = 68 /* AsteriskAsteriskEqualsToken */;
|
|
9390
9412
|
}
|
|
9391
9413
|
return pos += 2, token = 43 /* AsteriskAsteriskToken */;
|
|
@@ -9397,10 +9419,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9397
9419
|
}
|
|
9398
9420
|
return token = 42 /* AsteriskToken */;
|
|
9399
9421
|
case 43 /* plus */:
|
|
9400
|
-
if (
|
|
9422
|
+
if (charCodeUnchecked(pos + 1) === 43 /* plus */) {
|
|
9401
9423
|
return pos += 2, token = 46 /* PlusPlusToken */;
|
|
9402
9424
|
}
|
|
9403
|
-
if (
|
|
9425
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9404
9426
|
return pos += 2, token = 65 /* PlusEqualsToken */;
|
|
9405
9427
|
}
|
|
9406
9428
|
pos++;
|
|
@@ -9409,29 +9431,29 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9409
9431
|
pos++;
|
|
9410
9432
|
return token = 28 /* CommaToken */;
|
|
9411
9433
|
case 45 /* minus */:
|
|
9412
|
-
if (
|
|
9434
|
+
if (charCodeUnchecked(pos + 1) === 45 /* minus */) {
|
|
9413
9435
|
return pos += 2, token = 47 /* MinusMinusToken */;
|
|
9414
9436
|
}
|
|
9415
|
-
if (
|
|
9437
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9416
9438
|
return pos += 2, token = 66 /* MinusEqualsToken */;
|
|
9417
9439
|
}
|
|
9418
9440
|
pos++;
|
|
9419
9441
|
return token = 41 /* MinusToken */;
|
|
9420
9442
|
case 46 /* dot */:
|
|
9421
|
-
if (isDigit(
|
|
9443
|
+
if (isDigit(charCodeUnchecked(pos + 1))) {
|
|
9422
9444
|
scanNumber();
|
|
9423
9445
|
return token = 9 /* NumericLiteral */;
|
|
9424
9446
|
}
|
|
9425
|
-
if (
|
|
9447
|
+
if (charCodeUnchecked(pos + 1) === 46 /* dot */ && charCodeUnchecked(pos + 2) === 46 /* dot */) {
|
|
9426
9448
|
return pos += 3, token = 26 /* DotDotDotToken */;
|
|
9427
9449
|
}
|
|
9428
9450
|
pos++;
|
|
9429
9451
|
return token = 25 /* DotToken */;
|
|
9430
9452
|
case 47 /* slash */:
|
|
9431
|
-
if (
|
|
9453
|
+
if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
|
|
9432
9454
|
pos += 2;
|
|
9433
9455
|
while (pos < end) {
|
|
9434
|
-
if (isLineBreak(
|
|
9456
|
+
if (isLineBreak(charCodeUnchecked(pos))) {
|
|
9435
9457
|
break;
|
|
9436
9458
|
}
|
|
9437
9459
|
pos++;
|
|
@@ -9448,14 +9470,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9448
9470
|
return token = 2 /* SingleLineCommentTrivia */;
|
|
9449
9471
|
}
|
|
9450
9472
|
}
|
|
9451
|
-
if (
|
|
9473
|
+
if (charCodeUnchecked(pos + 1) === 42 /* asterisk */) {
|
|
9452
9474
|
pos += 2;
|
|
9453
|
-
const isJSDoc2 =
|
|
9475
|
+
const isJSDoc2 = charCodeUnchecked(pos) === 42 /* asterisk */ && charCodeUnchecked(pos + 1) !== 47 /* slash */;
|
|
9454
9476
|
let commentClosed = false;
|
|
9455
9477
|
let lastLineStart = tokenStart;
|
|
9456
9478
|
while (pos < end) {
|
|
9457
|
-
const ch2 =
|
|
9458
|
-
if (ch2 === 42 /* asterisk */ &&
|
|
9479
|
+
const ch2 = charCodeUnchecked(pos);
|
|
9480
|
+
if (ch2 === 42 /* asterisk */ && charCodeUnchecked(pos + 1) === 47 /* slash */) {
|
|
9459
9481
|
pos += 2;
|
|
9460
9482
|
commentClosed = true;
|
|
9461
9483
|
break;
|
|
@@ -9482,13 +9504,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9482
9504
|
return token = 3 /* MultiLineCommentTrivia */;
|
|
9483
9505
|
}
|
|
9484
9506
|
}
|
|
9485
|
-
if (
|
|
9507
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9486
9508
|
return pos += 2, token = 69 /* SlashEqualsToken */;
|
|
9487
9509
|
}
|
|
9488
9510
|
pos++;
|
|
9489
9511
|
return token = 44 /* SlashToken */;
|
|
9490
9512
|
case 48 /* _0 */:
|
|
9491
|
-
if (pos + 2 < end && (
|
|
9513
|
+
if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 88 /* X */ || charCodeUnchecked(pos + 1) === 120 /* x */)) {
|
|
9492
9514
|
pos += 2;
|
|
9493
9515
|
tokenValue = scanMinimumNumberOfHexDigits(
|
|
9494
9516
|
1,
|
|
@@ -9502,7 +9524,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9502
9524
|
tokenValue = "0x" + tokenValue;
|
|
9503
9525
|
tokenFlags |= 64 /* HexSpecifier */;
|
|
9504
9526
|
return token = checkBigIntSuffix();
|
|
9505
|
-
} else if (pos + 2 < end && (
|
|
9527
|
+
} else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 66 /* B */ || charCodeUnchecked(pos + 1) === 98 /* b */)) {
|
|
9506
9528
|
pos += 2;
|
|
9507
9529
|
tokenValue = scanBinaryOrOctalDigits(
|
|
9508
9530
|
/* base */
|
|
@@ -9515,7 +9537,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9515
9537
|
tokenValue = "0b" + tokenValue;
|
|
9516
9538
|
tokenFlags |= 128 /* BinarySpecifier */;
|
|
9517
9539
|
return token = checkBigIntSuffix();
|
|
9518
|
-
} else if (pos + 2 < end && (
|
|
9540
|
+
} else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 79 /* O */ || charCodeUnchecked(pos + 1) === 111 /* o */)) {
|
|
9519
9541
|
pos += 2;
|
|
9520
9542
|
tokenValue = scanBinaryOrOctalDigits(
|
|
9521
9543
|
/* base */
|
|
@@ -9554,16 +9576,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9554
9576
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
9555
9577
|
}
|
|
9556
9578
|
}
|
|
9557
|
-
if (
|
|
9558
|
-
if (
|
|
9579
|
+
if (charCodeUnchecked(pos + 1) === 60 /* lessThan */) {
|
|
9580
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9559
9581
|
return pos += 3, token = 71 /* LessThanLessThanEqualsToken */;
|
|
9560
9582
|
}
|
|
9561
9583
|
return pos += 2, token = 48 /* LessThanLessThanToken */;
|
|
9562
9584
|
}
|
|
9563
|
-
if (
|
|
9585
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9564
9586
|
return pos += 2, token = 33 /* LessThanEqualsToken */;
|
|
9565
9587
|
}
|
|
9566
|
-
if (languageVariant === 1 /* JSX */ &&
|
|
9588
|
+
if (languageVariant === 1 /* JSX */ && charCodeUnchecked(pos + 1) === 47 /* slash */ && charCodeUnchecked(pos + 2) !== 42 /* asterisk */) {
|
|
9567
9589
|
return pos += 2, token = 31 /* LessThanSlashToken */;
|
|
9568
9590
|
}
|
|
9569
9591
|
pos++;
|
|
@@ -9577,13 +9599,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9577
9599
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
9578
9600
|
}
|
|
9579
9601
|
}
|
|
9580
|
-
if (
|
|
9581
|
-
if (
|
|
9602
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9603
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9582
9604
|
return pos += 3, token = 37 /* EqualsEqualsEqualsToken */;
|
|
9583
9605
|
}
|
|
9584
9606
|
return pos += 2, token = 35 /* EqualsEqualsToken */;
|
|
9585
9607
|
}
|
|
9586
|
-
if (
|
|
9608
|
+
if (charCodeUnchecked(pos + 1) === 62 /* greaterThan */) {
|
|
9587
9609
|
return pos += 2, token = 39 /* EqualsGreaterThanToken */;
|
|
9588
9610
|
}
|
|
9589
9611
|
pos++;
|
|
@@ -9600,11 +9622,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9600
9622
|
pos++;
|
|
9601
9623
|
return token = 32 /* GreaterThanToken */;
|
|
9602
9624
|
case 63 /* question */:
|
|
9603
|
-
if (
|
|
9625
|
+
if (charCodeUnchecked(pos + 1) === 46 /* dot */ && !isDigit(charCodeUnchecked(pos + 2))) {
|
|
9604
9626
|
return pos += 2, token = 29 /* QuestionDotToken */;
|
|
9605
9627
|
}
|
|
9606
|
-
if (
|
|
9607
|
-
if (
|
|
9628
|
+
if (charCodeUnchecked(pos + 1) === 63 /* question */) {
|
|
9629
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9608
9630
|
return pos += 3, token = 78 /* QuestionQuestionEqualsToken */;
|
|
9609
9631
|
}
|
|
9610
9632
|
return pos += 2, token = 61 /* QuestionQuestionToken */;
|
|
@@ -9618,7 +9640,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9618
9640
|
pos++;
|
|
9619
9641
|
return token = 24 /* CloseBracketToken */;
|
|
9620
9642
|
case 94 /* caret */:
|
|
9621
|
-
if (
|
|
9643
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9622
9644
|
return pos += 2, token = 79 /* CaretEqualsToken */;
|
|
9623
9645
|
}
|
|
9624
9646
|
pos++;
|
|
@@ -9635,13 +9657,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9635
9657
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
9636
9658
|
}
|
|
9637
9659
|
}
|
|
9638
|
-
if (
|
|
9639
|
-
if (
|
|
9660
|
+
if (charCodeUnchecked(pos + 1) === 124 /* bar */) {
|
|
9661
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9640
9662
|
return pos += 3, token = 76 /* BarBarEqualsToken */;
|
|
9641
9663
|
}
|
|
9642
9664
|
return pos += 2, token = 57 /* BarBarToken */;
|
|
9643
9665
|
}
|
|
9644
|
-
if (
|
|
9666
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9645
9667
|
return pos += 2, token = 75 /* BarEqualsToken */;
|
|
9646
9668
|
}
|
|
9647
9669
|
pos++;
|
|
@@ -9680,7 +9702,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9680
9702
|
pos++;
|
|
9681
9703
|
return token = 0 /* Unknown */;
|
|
9682
9704
|
}
|
|
9683
|
-
const charAfterHash =
|
|
9705
|
+
const charAfterHash = codePointUnchecked(pos + 1);
|
|
9684
9706
|
if (charAfterHash === 92 /* backslash */) {
|
|
9685
9707
|
pos++;
|
|
9686
9708
|
const extendedCookedChar2 = peekExtendedUnicodeEscape();
|
|
@@ -9750,7 +9772,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9750
9772
|
Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
|
|
9751
9773
|
pos = tokenStart = fullStartPos;
|
|
9752
9774
|
tokenFlags = 0;
|
|
9753
|
-
const ch =
|
|
9775
|
+
const ch = codePointUnchecked(pos);
|
|
9754
9776
|
const identifierKind = scanIdentifier(ch, 99 /* ESNext */);
|
|
9755
9777
|
if (identifierKind) {
|
|
9756
9778
|
return token = identifierKind;
|
|
@@ -9762,7 +9784,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9762
9784
|
let ch = startCharacter;
|
|
9763
9785
|
if (isIdentifierStart(ch, languageVersion2)) {
|
|
9764
9786
|
pos += charSize(ch);
|
|
9765
|
-
while (pos < end && isIdentifierPart(ch =
|
|
9787
|
+
while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos), languageVersion2))
|
|
9766
9788
|
pos += charSize(ch);
|
|
9767
9789
|
tokenValue = text.substring(tokenStart, pos);
|
|
9768
9790
|
if (ch === 92 /* backslash */) {
|
|
@@ -9773,20 +9795,20 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9773
9795
|
}
|
|
9774
9796
|
function reScanGreaterToken() {
|
|
9775
9797
|
if (token === 32 /* GreaterThanToken */) {
|
|
9776
|
-
if (
|
|
9777
|
-
if (
|
|
9778
|
-
if (
|
|
9798
|
+
if (charCodeUnchecked(pos) === 62 /* greaterThan */) {
|
|
9799
|
+
if (charCodeUnchecked(pos + 1) === 62 /* greaterThan */) {
|
|
9800
|
+
if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
|
|
9779
9801
|
return pos += 3, token = 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
|
|
9780
9802
|
}
|
|
9781
9803
|
return pos += 2, token = 50 /* GreaterThanGreaterThanGreaterThanToken */;
|
|
9782
9804
|
}
|
|
9783
|
-
if (
|
|
9805
|
+
if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
|
|
9784
9806
|
return pos += 2, token = 72 /* GreaterThanGreaterThanEqualsToken */;
|
|
9785
9807
|
}
|
|
9786
9808
|
pos++;
|
|
9787
9809
|
return token = 49 /* GreaterThanGreaterThanToken */;
|
|
9788
9810
|
}
|
|
9789
|
-
if (
|
|
9811
|
+
if (charCodeUnchecked(pos) === 61 /* equals */) {
|
|
9790
9812
|
pos++;
|
|
9791
9813
|
return token = 34 /* GreaterThanEqualsToken */;
|
|
9792
9814
|
}
|
|
@@ -9809,7 +9831,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9809
9831
|
error(Diagnostics.Unterminated_regular_expression_literal);
|
|
9810
9832
|
break;
|
|
9811
9833
|
}
|
|
9812
|
-
const ch =
|
|
9834
|
+
const ch = charCodeUnchecked(p);
|
|
9813
9835
|
if (isLineBreak(ch)) {
|
|
9814
9836
|
tokenFlags |= 4 /* Unterminated */;
|
|
9815
9837
|
error(Diagnostics.Unterminated_regular_expression_literal);
|
|
@@ -9833,7 +9855,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9833
9855
|
const endOfBody = p - (isUnterminated ? 0 : 1);
|
|
9834
9856
|
let regExpFlags = 0 /* None */;
|
|
9835
9857
|
while (p < end) {
|
|
9836
|
-
const ch =
|
|
9858
|
+
const ch = charCodeUnchecked(p);
|
|
9837
9859
|
if (!isIdentifierPart(ch, languageVersion)) {
|
|
9838
9860
|
break;
|
|
9839
9861
|
}
|
|
@@ -9852,845 +9874,860 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9852
9874
|
}
|
|
9853
9875
|
p++;
|
|
9854
9876
|
}
|
|
9877
|
+
pos = p;
|
|
9855
9878
|
if (reportErrors2) {
|
|
9856
|
-
|
|
9857
|
-
const saveTokenPos = tokenStart;
|
|
9879
|
+
const saveTokenStart = tokenStart;
|
|
9858
9880
|
const saveTokenFlags = tokenFlags;
|
|
9881
|
+
const savePos = pos;
|
|
9882
|
+
const saveEnd = end;
|
|
9883
|
+
pos = tokenStart + 1;
|
|
9884
|
+
end = endOfBody;
|
|
9859
9885
|
scanRegularExpressionWorker(
|
|
9860
|
-
text,
|
|
9861
|
-
endOfBody,
|
|
9862
9886
|
regExpFlags,
|
|
9863
9887
|
isUnterminated,
|
|
9864
9888
|
/*annexB*/
|
|
9865
9889
|
true
|
|
9866
9890
|
);
|
|
9867
|
-
|
|
9868
|
-
pos = p;
|
|
9869
|
-
}
|
|
9870
|
-
tokenStart = saveTokenPos;
|
|
9891
|
+
tokenStart = saveTokenStart;
|
|
9871
9892
|
tokenFlags = saveTokenFlags;
|
|
9872
|
-
|
|
9873
|
-
|
|
9893
|
+
pos = savePos;
|
|
9894
|
+
end = saveEnd;
|
|
9874
9895
|
}
|
|
9875
9896
|
tokenValue = text.substring(tokenStart, pos);
|
|
9876
9897
|
token = 14 /* RegularExpressionLiteral */;
|
|
9877
9898
|
}
|
|
9878
9899
|
return token;
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
+
}
|
|
9901
|
+
function scanRegularExpressionWorker(regExpFlags, isUnterminated, annexB) {
|
|
9902
|
+
var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
|
|
9903
|
+
var unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
9904
|
+
if (unicodeMode) {
|
|
9905
|
+
annexB = false;
|
|
9906
|
+
}
|
|
9907
|
+
var mayContainStrings = false;
|
|
9908
|
+
var numberOfCapturingGroups = 0;
|
|
9909
|
+
var groupSpecifiers;
|
|
9910
|
+
var groupNameReferences;
|
|
9911
|
+
var decimalEscapes;
|
|
9912
|
+
var namedCapturingGroupsScopeStack = [];
|
|
9913
|
+
var topNamedCapturingGroupsScope;
|
|
9914
|
+
function scanDisjunction(isInGroup) {
|
|
9915
|
+
while (true) {
|
|
9916
|
+
namedCapturingGroupsScopeStack.push(topNamedCapturingGroupsScope);
|
|
9917
|
+
topNamedCapturingGroupsScope = void 0;
|
|
9918
|
+
scanAlternative(isInGroup);
|
|
9919
|
+
topNamedCapturingGroupsScope = namedCapturingGroupsScopeStack.pop();
|
|
9920
|
+
if (charCodeChecked(pos) !== 124 /* bar */) {
|
|
9921
|
+
return;
|
|
9900
9922
|
}
|
|
9923
|
+
pos++;
|
|
9901
9924
|
}
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9925
|
+
}
|
|
9926
|
+
function scanAlternative(isInGroup) {
|
|
9927
|
+
let isPreviousTermQuantifiable = false;
|
|
9928
|
+
while (true) {
|
|
9929
|
+
const start2 = pos;
|
|
9930
|
+
const ch = charCodeChecked(pos);
|
|
9931
|
+
switch (ch) {
|
|
9932
|
+
case -1 /* EOF */:
|
|
9933
|
+
return;
|
|
9934
|
+
case 94 /* caret */:
|
|
9935
|
+
case 36 /* $ */:
|
|
9936
|
+
pos++;
|
|
9937
|
+
isPreviousTermQuantifiable = false;
|
|
9938
|
+
break;
|
|
9939
|
+
case 92 /* backslash */:
|
|
9940
|
+
pos++;
|
|
9941
|
+
switch (charCodeChecked(pos)) {
|
|
9942
|
+
case 98 /* b */:
|
|
9943
|
+
case 66 /* B */:
|
|
9944
|
+
pos++;
|
|
9945
|
+
isPreviousTermQuantifiable = false;
|
|
9946
|
+
break;
|
|
9947
|
+
default:
|
|
9948
|
+
scanAtomEscape();
|
|
9949
|
+
isPreviousTermQuantifiable = true;
|
|
9950
|
+
break;
|
|
9951
|
+
}
|
|
9952
|
+
break;
|
|
9953
|
+
case 40 /* openParen */:
|
|
9954
|
+
pos++;
|
|
9955
|
+
if (charCodeChecked(pos) === 63 /* question */) {
|
|
9914
9956
|
pos++;
|
|
9915
|
-
switch (
|
|
9916
|
-
case
|
|
9917
|
-
case
|
|
9957
|
+
switch (charCodeChecked(pos)) {
|
|
9958
|
+
case 61 /* equals */:
|
|
9959
|
+
case 33 /* exclamation */:
|
|
9918
9960
|
pos++;
|
|
9919
|
-
isPreviousTermQuantifiable =
|
|
9920
|
-
break;
|
|
9921
|
-
default:
|
|
9922
|
-
scanAtomEscape();
|
|
9923
|
-
isPreviousTermQuantifiable = true;
|
|
9961
|
+
isPreviousTermQuantifiable = annexB;
|
|
9924
9962
|
break;
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
switch (text2.charCodeAt(pos)) {
|
|
9932
|
-
case 61 /* equals */:
|
|
9933
|
-
case 33 /* exclamation */:
|
|
9934
|
-
pos++;
|
|
9935
|
-
isPreviousTermQuantifiable = annexB;
|
|
9936
|
-
break;
|
|
9937
|
-
case 60 /* lessThan */:
|
|
9938
|
-
const groupNameStart = pos;
|
|
9939
|
-
pos++;
|
|
9940
|
-
switch (text2.charCodeAt(pos)) {
|
|
9941
|
-
case 61 /* equals */:
|
|
9942
|
-
case 33 /* exclamation */:
|
|
9943
|
-
pos++;
|
|
9944
|
-
isPreviousTermQuantifiable = false;
|
|
9945
|
-
break;
|
|
9946
|
-
default:
|
|
9947
|
-
scanGroupName(
|
|
9948
|
-
/*isReference*/
|
|
9949
|
-
false
|
|
9950
|
-
);
|
|
9951
|
-
scanExpectedChar(62 /* greaterThan */);
|
|
9952
|
-
if (languageVersion < 5 /* ES2018 */) {
|
|
9953
|
-
error(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
|
|
9954
|
-
}
|
|
9955
|
-
numberOfCapturingGroups++;
|
|
9956
|
-
isPreviousTermQuantifiable = true;
|
|
9957
|
-
break;
|
|
9958
|
-
}
|
|
9959
|
-
break;
|
|
9960
|
-
default:
|
|
9961
|
-
const start3 = pos;
|
|
9962
|
-
const setFlags = scanPatternModifiers(0 /* None */);
|
|
9963
|
-
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
9963
|
+
case 60 /* lessThan */:
|
|
9964
|
+
const groupNameStart = pos;
|
|
9965
|
+
pos++;
|
|
9966
|
+
switch (charCodeChecked(pos)) {
|
|
9967
|
+
case 61 /* equals */:
|
|
9968
|
+
case 33 /* exclamation */:
|
|
9964
9969
|
pos++;
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9970
|
+
isPreviousTermQuantifiable = false;
|
|
9971
|
+
break;
|
|
9972
|
+
default:
|
|
9973
|
+
scanGroupName(
|
|
9974
|
+
/*isReference*/
|
|
9975
|
+
false
|
|
9976
|
+
);
|
|
9977
|
+
scanExpectedChar(62 /* greaterThan */);
|
|
9978
|
+
if (languageVersion < 5 /* ES2018 */) {
|
|
9979
|
+
error(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
|
|
9968
9980
|
}
|
|
9981
|
+
numberOfCapturingGroups++;
|
|
9982
|
+
isPreviousTermQuantifiable = true;
|
|
9983
|
+
break;
|
|
9984
|
+
}
|
|
9985
|
+
break;
|
|
9986
|
+
default:
|
|
9987
|
+
const start3 = pos;
|
|
9988
|
+
const setFlags = scanPatternModifiers(0 /* None */);
|
|
9989
|
+
if (charCodeChecked(pos) === 45 /* minus */) {
|
|
9990
|
+
pos++;
|
|
9991
|
+
scanPatternModifiers(setFlags);
|
|
9992
|
+
if (pos === start3 + 1) {
|
|
9993
|
+
error(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
|
|
9969
9994
|
}
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
} else {
|
|
9975
|
-
numberOfCapturingGroups++;
|
|
9976
|
-
isPreviousTermQuantifiable = true;
|
|
9995
|
+
}
|
|
9996
|
+
scanExpectedChar(58 /* colon */);
|
|
9997
|
+
isPreviousTermQuantifiable = true;
|
|
9998
|
+
break;
|
|
9977
9999
|
}
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
10000
|
+
} else {
|
|
10001
|
+
numberOfCapturingGroups++;
|
|
10002
|
+
isPreviousTermQuantifiable = true;
|
|
10003
|
+
}
|
|
10004
|
+
scanDisjunction(
|
|
10005
|
+
/*isInGroup*/
|
|
10006
|
+
true
|
|
10007
|
+
);
|
|
10008
|
+
scanExpectedChar(41 /* closeParen */);
|
|
10009
|
+
break;
|
|
10010
|
+
case 123 /* openBrace */:
|
|
10011
|
+
pos++;
|
|
10012
|
+
const digitsStart = pos;
|
|
10013
|
+
scanDigits();
|
|
10014
|
+
const min2 = tokenValue;
|
|
10015
|
+
if (charCodeChecked(pos) === 44 /* comma */) {
|
|
9985
10016
|
pos++;
|
|
9986
|
-
const digitsStart = pos;
|
|
9987
10017
|
scanDigits();
|
|
9988
|
-
const
|
|
9989
|
-
if (
|
|
9990
|
-
pos
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
|
|
9996
|
-
} else {
|
|
9997
|
-
if (unicodeMode) {
|
|
9998
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
9999
|
-
}
|
|
10000
|
-
isPreviousTermQuantifiable = true;
|
|
10001
|
-
break;
|
|
10018
|
+
const max = tokenValue;
|
|
10019
|
+
if (!min2) {
|
|
10020
|
+
if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
|
|
10021
|
+
error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
|
|
10022
|
+
} else {
|
|
10023
|
+
if (unicodeMode) {
|
|
10024
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
10002
10025
|
}
|
|
10026
|
+
isPreviousTermQuantifiable = true;
|
|
10027
|
+
break;
|
|
10003
10028
|
}
|
|
10004
|
-
if (max && Number.parseInt(min2) > Number.parseInt(max)) {
|
|
10005
|
-
error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
|
|
10006
|
-
}
|
|
10007
|
-
} else if (!min2) {
|
|
10008
|
-
if (unicodeMode) {
|
|
10009
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
10010
|
-
}
|
|
10011
|
-
isPreviousTermQuantifiable = true;
|
|
10012
|
-
break;
|
|
10013
|
-
}
|
|
10014
|
-
scanExpectedChar(125 /* closeBrace */);
|
|
10015
|
-
pos--;
|
|
10016
|
-
case 42 /* asterisk */:
|
|
10017
|
-
case 43 /* plus */:
|
|
10018
|
-
case 63 /* question */:
|
|
10019
|
-
pos++;
|
|
10020
|
-
if (text2.charCodeAt(pos) === 63 /* question */) {
|
|
10021
|
-
pos++;
|
|
10022
|
-
}
|
|
10023
|
-
if (!isPreviousTermQuantifiable) {
|
|
10024
|
-
error(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
|
|
10025
|
-
}
|
|
10026
|
-
isPreviousTermQuantifiable = false;
|
|
10027
|
-
break;
|
|
10028
|
-
case 46 /* dot */:
|
|
10029
|
-
pos++;
|
|
10030
|
-
isPreviousTermQuantifiable = true;
|
|
10031
|
-
break;
|
|
10032
|
-
case 91 /* openBracket */:
|
|
10033
|
-
pos++;
|
|
10034
|
-
if (unicodeSetsMode) {
|
|
10035
|
-
scanClassSetExpression();
|
|
10036
|
-
} else {
|
|
10037
|
-
scanClassRanges();
|
|
10038
|
-
}
|
|
10039
|
-
scanExpectedChar(93 /* closeBracket */);
|
|
10040
|
-
isPreviousTermQuantifiable = true;
|
|
10041
|
-
break;
|
|
10042
|
-
case 41 /* closeParen */:
|
|
10043
|
-
if (isInGroup) {
|
|
10044
|
-
return;
|
|
10045
10029
|
}
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
if (isUnterminated && !isInGroup) {
|
|
10049
|
-
return;
|
|
10030
|
+
if (max && Number.parseInt(min2) > Number.parseInt(max)) {
|
|
10031
|
+
error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
|
|
10050
10032
|
}
|
|
10051
|
-
|
|
10052
|
-
|
|
10033
|
+
} else if (!min2) {
|
|
10034
|
+
if (unicodeMode) {
|
|
10035
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
10053
10036
|
}
|
|
10054
|
-
pos++;
|
|
10055
|
-
isPreviousTermQuantifiable = true;
|
|
10056
|
-
break;
|
|
10057
|
-
case 47 /* slash */:
|
|
10058
|
-
case 124 /* bar */:
|
|
10059
|
-
return;
|
|
10060
|
-
default:
|
|
10061
|
-
scanSourceCharacter();
|
|
10062
10037
|
isPreviousTermQuantifiable = true;
|
|
10063
10038
|
break;
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
if (!isIdentifierPart(ch, languageVersion)) {
|
|
10071
|
-
break;
|
|
10072
|
-
}
|
|
10073
|
-
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
10074
|
-
if (flag === void 0) {
|
|
10075
|
-
error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
|
|
10076
|
-
} else if (currFlags & flag) {
|
|
10077
|
-
error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
|
|
10078
|
-
} else if (!(flag & 28 /* Modifiers */)) {
|
|
10079
|
-
error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
|
|
10080
|
-
} else {
|
|
10081
|
-
currFlags |= flag;
|
|
10082
|
-
checkRegularExpressionFlagAvailable(flag, pos);
|
|
10083
|
-
}
|
|
10084
|
-
pos++;
|
|
10085
|
-
}
|
|
10086
|
-
return currFlags;
|
|
10087
|
-
}
|
|
10088
|
-
function scanAtomEscape() {
|
|
10089
|
-
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10090
|
-
switch (text2.charCodeAt(pos)) {
|
|
10091
|
-
case 107 /* k */:
|
|
10039
|
+
}
|
|
10040
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
10041
|
+
pos--;
|
|
10042
|
+
case 42 /* asterisk */:
|
|
10043
|
+
case 43 /* plus */:
|
|
10044
|
+
case 63 /* question */:
|
|
10092
10045
|
pos++;
|
|
10093
|
-
if (
|
|
10046
|
+
if (charCodeChecked(pos) === 63 /* question */) {
|
|
10094
10047
|
pos++;
|
|
10095
|
-
scanGroupName(
|
|
10096
|
-
/*isReference*/
|
|
10097
|
-
true
|
|
10098
|
-
);
|
|
10099
|
-
scanExpectedChar(62 /* greaterThan */);
|
|
10100
|
-
} else if (unicodeMode) {
|
|
10101
|
-
error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
|
|
10102
10048
|
}
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
if (unicodeSetsMode) {
|
|
10106
|
-
pos++;
|
|
10107
|
-
error(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
|
|
10108
|
-
break;
|
|
10049
|
+
if (!isPreviousTermQuantifiable) {
|
|
10050
|
+
error(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
|
|
10109
10051
|
}
|
|
10110
|
-
|
|
10111
|
-
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
|
|
10112
|
-
/*atomEscape*/
|
|
10113
|
-
true
|
|
10114
|
-
));
|
|
10052
|
+
isPreviousTermQuantifiable = false;
|
|
10115
10053
|
break;
|
|
10116
|
-
|
|
10117
|
-
}
|
|
10118
|
-
function scanDecimalEscape() {
|
|
10119
|
-
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10120
|
-
const ch = text2.charCodeAt(pos);
|
|
10121
|
-
if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
|
|
10122
|
-
const start2 = pos;
|
|
10123
|
-
scanDigits();
|
|
10124
|
-
decimalEscapes.push({ pos: start2, end: pos, value: +tokenValue });
|
|
10125
|
-
return true;
|
|
10126
|
-
}
|
|
10127
|
-
return false;
|
|
10128
|
-
}
|
|
10129
|
-
function scanCharacterEscape(atomEscape) {
|
|
10130
|
-
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10131
|
-
let ch = text2.charCodeAt(pos);
|
|
10132
|
-
switch (ch) {
|
|
10133
|
-
case 99 /* c */:
|
|
10054
|
+
case 46 /* dot */:
|
|
10134
10055
|
pos++;
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
pos--;
|
|
10144
|
-
return "\\";
|
|
10056
|
+
isPreviousTermQuantifiable = true;
|
|
10057
|
+
break;
|
|
10058
|
+
case 91 /* openBracket */:
|
|
10059
|
+
pos++;
|
|
10060
|
+
if (unicodeSetsMode) {
|
|
10061
|
+
scanClassSetExpression();
|
|
10062
|
+
} else {
|
|
10063
|
+
scanClassRanges();
|
|
10145
10064
|
}
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
case 47 /* slash */:
|
|
10150
|
-
case 92 /* backslash */:
|
|
10151
|
-
case 46 /* dot */:
|
|
10152
|
-
case 42 /* asterisk */:
|
|
10153
|
-
case 43 /* plus */:
|
|
10154
|
-
case 63 /* question */:
|
|
10155
|
-
case 40 /* openParen */:
|
|
10065
|
+
scanExpectedChar(93 /* closeBracket */);
|
|
10066
|
+
isPreviousTermQuantifiable = true;
|
|
10067
|
+
break;
|
|
10156
10068
|
case 41 /* closeParen */:
|
|
10157
|
-
|
|
10069
|
+
if (isInGroup) {
|
|
10070
|
+
return;
|
|
10071
|
+
}
|
|
10158
10072
|
case 93 /* closeBracket */:
|
|
10159
|
-
case 123 /* openBrace */:
|
|
10160
10073
|
case 125 /* closeBrace */:
|
|
10161
|
-
|
|
10074
|
+
if (isUnterminated && !isInGroup) {
|
|
10075
|
+
return;
|
|
10076
|
+
}
|
|
10077
|
+
if (unicodeMode || ch === 41 /* closeParen */) {
|
|
10078
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10079
|
+
}
|
|
10162
10080
|
pos++;
|
|
10163
|
-
|
|
10081
|
+
isPreviousTermQuantifiable = true;
|
|
10082
|
+
break;
|
|
10083
|
+
case 47 /* slash */:
|
|
10084
|
+
case 124 /* bar */:
|
|
10085
|
+
return;
|
|
10164
10086
|
default:
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
}
|
|
10169
|
-
pos--;
|
|
10170
|
-
return scanEscapeSequence(
|
|
10171
|
-
/*shouldEmitInvalidEscapeError*/
|
|
10172
|
-
unicodeMode,
|
|
10173
|
-
/*isRegularExpression*/
|
|
10174
|
-
annexB ? "annex-b" : true
|
|
10175
|
-
);
|
|
10087
|
+
scanSourceCharacter();
|
|
10088
|
+
isPreviousTermQuantifiable = true;
|
|
10089
|
+
break;
|
|
10176
10090
|
}
|
|
10177
10091
|
}
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
if (
|
|
10183
|
-
|
|
10184
|
-
}
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
error(Diagnostics.
|
|
10092
|
+
}
|
|
10093
|
+
function scanPatternModifiers(currFlags) {
|
|
10094
|
+
while (true) {
|
|
10095
|
+
const ch = charCodeChecked(pos);
|
|
10096
|
+
if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
|
|
10097
|
+
break;
|
|
10098
|
+
}
|
|
10099
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
10100
|
+
if (flag === void 0) {
|
|
10101
|
+
error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
|
|
10102
|
+
} else if (currFlags & flag) {
|
|
10103
|
+
error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
|
|
10104
|
+
} else if (!(flag & 28 /* Modifiers */)) {
|
|
10105
|
+
error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
|
|
10188
10106
|
} else {
|
|
10189
|
-
|
|
10190
|
-
|
|
10107
|
+
currFlags |= flag;
|
|
10108
|
+
checkRegularExpressionFlagAvailable(flag, pos);
|
|
10191
10109
|
}
|
|
10110
|
+
pos++;
|
|
10111
|
+
}
|
|
10112
|
+
return currFlags;
|
|
10113
|
+
}
|
|
10114
|
+
function scanAtomEscape() {
|
|
10115
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
|
|
10116
|
+
switch (charCodeChecked(pos)) {
|
|
10117
|
+
case 107 /* k */:
|
|
10118
|
+
pos++;
|
|
10119
|
+
if (charCodeChecked(pos) === 60 /* lessThan */) {
|
|
10120
|
+
pos++;
|
|
10121
|
+
scanGroupName(
|
|
10122
|
+
/*isReference*/
|
|
10123
|
+
true
|
|
10124
|
+
);
|
|
10125
|
+
scanExpectedChar(62 /* greaterThan */);
|
|
10126
|
+
} else if (unicodeMode) {
|
|
10127
|
+
error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
|
|
10128
|
+
}
|
|
10129
|
+
break;
|
|
10130
|
+
case 113 /* q */:
|
|
10131
|
+
if (unicodeSetsMode) {
|
|
10132
|
+
pos++;
|
|
10133
|
+
error(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
|
|
10134
|
+
break;
|
|
10135
|
+
}
|
|
10136
|
+
default:
|
|
10137
|
+
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
|
|
10138
|
+
/*atomEscape*/
|
|
10139
|
+
true
|
|
10140
|
+
));
|
|
10141
|
+
break;
|
|
10142
|
+
}
|
|
10143
|
+
}
|
|
10144
|
+
function scanDecimalEscape() {
|
|
10145
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
|
|
10146
|
+
const ch = charCodeChecked(pos);
|
|
10147
|
+
if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
|
|
10148
|
+
const start2 = pos;
|
|
10149
|
+
scanDigits();
|
|
10150
|
+
decimalEscapes = append(decimalEscapes, { pos: start2, end: pos, value: +tokenValue });
|
|
10151
|
+
return true;
|
|
10152
|
+
}
|
|
10153
|
+
return false;
|
|
10154
|
+
}
|
|
10155
|
+
function scanCharacterEscape(atomEscape) {
|
|
10156
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
|
|
10157
|
+
let ch = charCodeChecked(pos);
|
|
10158
|
+
switch (ch) {
|
|
10159
|
+
case 99 /* c */:
|
|
10160
|
+
pos++;
|
|
10161
|
+
ch = charCodeChecked(pos);
|
|
10162
|
+
if (isASCIILetter(ch)) {
|
|
10163
|
+
pos++;
|
|
10164
|
+
return String.fromCharCode(ch & 31);
|
|
10165
|
+
}
|
|
10166
|
+
if (unicodeMode) {
|
|
10167
|
+
error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
|
|
10168
|
+
} else if (atomEscape && annexB) {
|
|
10169
|
+
pos--;
|
|
10170
|
+
return "\\";
|
|
10171
|
+
}
|
|
10172
|
+
return String.fromCharCode(ch);
|
|
10173
|
+
case 94 /* caret */:
|
|
10174
|
+
case 36 /* $ */:
|
|
10175
|
+
case 47 /* slash */:
|
|
10176
|
+
case 92 /* backslash */:
|
|
10177
|
+
case 46 /* dot */:
|
|
10178
|
+
case 42 /* asterisk */:
|
|
10179
|
+
case 43 /* plus */:
|
|
10180
|
+
case 63 /* question */:
|
|
10181
|
+
case 40 /* openParen */:
|
|
10182
|
+
case 41 /* closeParen */:
|
|
10183
|
+
case 91 /* openBracket */:
|
|
10184
|
+
case 93 /* closeBracket */:
|
|
10185
|
+
case 123 /* openBrace */:
|
|
10186
|
+
case 125 /* closeBrace */:
|
|
10187
|
+
case 124 /* bar */:
|
|
10188
|
+
pos++;
|
|
10189
|
+
return String.fromCharCode(ch);
|
|
10190
|
+
default:
|
|
10191
|
+
if (pos >= end) {
|
|
10192
|
+
error(Diagnostics.Undetermined_character_escape, pos - 1, 1);
|
|
10193
|
+
return "\\";
|
|
10194
|
+
}
|
|
10195
|
+
pos--;
|
|
10196
|
+
return scanEscapeSequence(
|
|
10197
|
+
/*shouldEmitInvalidEscapeError*/
|
|
10198
|
+
unicodeMode,
|
|
10199
|
+
/*isRegularExpression*/
|
|
10200
|
+
annexB ? "annex-b" : true
|
|
10201
|
+
);
|
|
10202
|
+
}
|
|
10203
|
+
}
|
|
10204
|
+
function scanGroupName(isReference) {
|
|
10205
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 60 /* lessThan */);
|
|
10206
|
+
tokenStart = pos;
|
|
10207
|
+
scanIdentifier(codePointChecked(pos), languageVersion);
|
|
10208
|
+
if (pos === tokenStart) {
|
|
10209
|
+
error(Diagnostics.Expected_a_capturing_group_name);
|
|
10210
|
+
} else if (isReference) {
|
|
10211
|
+
groupNameReferences = append(groupNameReferences, { pos: tokenStart, end: pos, name: tokenValue });
|
|
10212
|
+
} else if ((topNamedCapturingGroupsScope == null ? void 0 : topNamedCapturingGroupsScope.has(tokenValue)) || namedCapturingGroupsScopeStack.some((group2) => group2 == null ? void 0 : group2.has(tokenValue))) {
|
|
10213
|
+
error(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
|
|
10214
|
+
} else {
|
|
10215
|
+
topNamedCapturingGroupsScope ?? (topNamedCapturingGroupsScope = /* @__PURE__ */ new Set());
|
|
10216
|
+
topNamedCapturingGroupsScope.add(tokenValue);
|
|
10217
|
+
groupSpecifiers ?? (groupSpecifiers = /* @__PURE__ */ new Set());
|
|
10218
|
+
groupSpecifiers.add(tokenValue);
|
|
10192
10219
|
}
|
|
10193
|
-
|
|
10194
|
-
|
|
10220
|
+
}
|
|
10221
|
+
function isClassContentExit(ch) {
|
|
10222
|
+
return ch === 93 /* closeBracket */ || ch === -1 /* EOF */ || pos >= end;
|
|
10223
|
+
}
|
|
10224
|
+
function scanClassRanges() {
|
|
10225
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 91 /* openBracket */);
|
|
10226
|
+
if (charCodeChecked(pos) === 94 /* caret */) {
|
|
10227
|
+
pos++;
|
|
10195
10228
|
}
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
if (
|
|
10229
|
+
while (true) {
|
|
10230
|
+
const ch = charCodeChecked(pos);
|
|
10231
|
+
if (isClassContentExit(ch)) {
|
|
10232
|
+
return;
|
|
10233
|
+
}
|
|
10234
|
+
const minStart = pos;
|
|
10235
|
+
const minCharacter = scanClassAtom();
|
|
10236
|
+
if (charCodeChecked(pos) === 45 /* minus */) {
|
|
10199
10237
|
pos++;
|
|
10238
|
+
const ch2 = charCodeChecked(pos);
|
|
10239
|
+
if (isClassContentExit(ch2)) {
|
|
10240
|
+
return;
|
|
10241
|
+
}
|
|
10242
|
+
if (!minCharacter && !annexB) {
|
|
10243
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
|
|
10244
|
+
}
|
|
10245
|
+
const maxStart = pos;
|
|
10246
|
+
const maxCharacter = scanClassAtom();
|
|
10247
|
+
if (!maxCharacter && !annexB) {
|
|
10248
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
|
|
10249
|
+
continue;
|
|
10250
|
+
}
|
|
10251
|
+
if (!minCharacter) {
|
|
10252
|
+
continue;
|
|
10253
|
+
}
|
|
10254
|
+
const minCharacterValue = codePointAt(minCharacter, 0);
|
|
10255
|
+
const maxCharacterValue = codePointAt(maxCharacter, 0);
|
|
10256
|
+
if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
10257
|
+
error(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
|
|
10258
|
+
}
|
|
10200
10259
|
}
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
function scanClassSetExpression() {
|
|
10263
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 91 /* openBracket */);
|
|
10264
|
+
let isCharacterComplement = false;
|
|
10265
|
+
if (charCodeChecked(pos) === 94 /* caret */) {
|
|
10266
|
+
pos++;
|
|
10267
|
+
isCharacterComplement = true;
|
|
10268
|
+
}
|
|
10269
|
+
let expressionMayContainStrings = false;
|
|
10270
|
+
let ch = charCodeChecked(pos);
|
|
10271
|
+
if (isClassContentExit(ch)) {
|
|
10272
|
+
return;
|
|
10273
|
+
}
|
|
10274
|
+
let start2 = pos;
|
|
10275
|
+
let operand;
|
|
10276
|
+
switch (text.slice(pos, pos + 2)) {
|
|
10277
|
+
case "--":
|
|
10278
|
+
case "&&":
|
|
10279
|
+
error(Diagnostics.Expected_a_class_set_operand);
|
|
10280
|
+
mayContainStrings = false;
|
|
10281
|
+
break;
|
|
10282
|
+
default:
|
|
10283
|
+
operand = scanClassSetOperand();
|
|
10284
|
+
break;
|
|
10285
|
+
}
|
|
10286
|
+
switch (charCodeChecked(pos)) {
|
|
10287
|
+
case 45 /* minus */:
|
|
10288
|
+
if (charCodeChecked(pos + 1) === 45 /* minus */) {
|
|
10289
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10290
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
10291
|
+
}
|
|
10292
|
+
expressionMayContainStrings = mayContainStrings;
|
|
10293
|
+
scanClassSetSubExpression(3 /* ClassSubtraction */);
|
|
10294
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10204
10295
|
return;
|
|
10205
10296
|
}
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
if (
|
|
10297
|
+
break;
|
|
10298
|
+
case 38 /* ampersand */:
|
|
10299
|
+
if (charCodeChecked(pos + 1) === 38 /* ampersand */) {
|
|
10300
|
+
scanClassSetSubExpression(2 /* ClassIntersection */);
|
|
10301
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10302
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
10303
|
+
}
|
|
10304
|
+
expressionMayContainStrings = mayContainStrings;
|
|
10305
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10306
|
+
return;
|
|
10307
|
+
} else {
|
|
10308
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10309
|
+
}
|
|
10310
|
+
break;
|
|
10311
|
+
default:
|
|
10312
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10313
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
10314
|
+
}
|
|
10315
|
+
expressionMayContainStrings = mayContainStrings;
|
|
10316
|
+
break;
|
|
10317
|
+
}
|
|
10318
|
+
while (true) {
|
|
10319
|
+
ch = charCodeChecked(pos);
|
|
10320
|
+
if (ch === -1 /* EOF */) {
|
|
10321
|
+
break;
|
|
10322
|
+
}
|
|
10323
|
+
switch (ch) {
|
|
10324
|
+
case 45 /* minus */:
|
|
10209
10325
|
pos++;
|
|
10210
|
-
|
|
10211
|
-
if (isClassContentExit(
|
|
10326
|
+
ch = charCodeChecked(pos);
|
|
10327
|
+
if (isClassContentExit(ch)) {
|
|
10328
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10212
10329
|
return;
|
|
10213
10330
|
}
|
|
10214
|
-
if (
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
if (!maxCharacter && !annexB) {
|
|
10220
|
-
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
|
|
10221
|
-
continue;
|
|
10222
|
-
}
|
|
10223
|
-
if (!minCharacter) {
|
|
10331
|
+
if (ch === 45 /* minus */) {
|
|
10332
|
+
pos++;
|
|
10333
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10334
|
+
start2 = pos - 2;
|
|
10335
|
+
operand = text.slice(start2, pos);
|
|
10224
10336
|
continue;
|
|
10337
|
+
} else {
|
|
10338
|
+
if (!operand) {
|
|
10339
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
|
|
10340
|
+
}
|
|
10341
|
+
const secondStart = pos;
|
|
10342
|
+
const secondOperand = scanClassSetOperand();
|
|
10343
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10344
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
|
|
10345
|
+
}
|
|
10346
|
+
expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
|
|
10347
|
+
if (!secondOperand) {
|
|
10348
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
|
|
10349
|
+
break;
|
|
10350
|
+
}
|
|
10351
|
+
if (!operand) {
|
|
10352
|
+
break;
|
|
10353
|
+
}
|
|
10354
|
+
const minCharacterValue = codePointAt(operand, 0);
|
|
10355
|
+
const maxCharacterValue = codePointAt(secondOperand, 0);
|
|
10356
|
+
if (operand.length === charSize(minCharacterValue) && secondOperand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
10357
|
+
error(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
|
|
10358
|
+
}
|
|
10225
10359
|
}
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10360
|
+
break;
|
|
10361
|
+
case 38 /* ampersand */:
|
|
10362
|
+
start2 = pos;
|
|
10363
|
+
pos++;
|
|
10364
|
+
if (charCodeChecked(pos) === 38 /* ampersand */) {
|
|
10365
|
+
pos++;
|
|
10366
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10367
|
+
if (charCodeChecked(pos) === 38 /* ampersand */) {
|
|
10368
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10369
|
+
pos++;
|
|
10370
|
+
}
|
|
10371
|
+
} else {
|
|
10372
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
10230
10373
|
}
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
}
|
|
10234
|
-
function scanClassSetExpression() {
|
|
10235
|
-
Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
|
|
10236
|
-
let isCharacterComplement = false;
|
|
10237
|
-
if (text2.charCodeAt(pos) === 94 /* caret */) {
|
|
10238
|
-
pos++;
|
|
10239
|
-
isCharacterComplement = true;
|
|
10374
|
+
operand = text.slice(start2, pos);
|
|
10375
|
+
continue;
|
|
10240
10376
|
}
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
if (isClassContentExit(ch)) {
|
|
10244
|
-
return;
|
|
10377
|
+
if (isClassContentExit(charCodeChecked(pos))) {
|
|
10378
|
+
break;
|
|
10245
10379
|
}
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
switch (text2.slice(pos, pos + 2)) {
|
|
10380
|
+
start2 = pos;
|
|
10381
|
+
switch (text.slice(pos, pos + 2)) {
|
|
10249
10382
|
case "--":
|
|
10250
10383
|
case "&&":
|
|
10251
|
-
error(Diagnostics.
|
|
10252
|
-
|
|
10384
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
|
|
10385
|
+
pos += 2;
|
|
10386
|
+
operand = text.slice(start2, pos);
|
|
10253
10387
|
break;
|
|
10254
10388
|
default:
|
|
10255
|
-
|
|
10389
|
+
operand = scanClassSetOperand();
|
|
10256
10390
|
break;
|
|
10257
10391
|
}
|
|
10258
|
-
|
|
10392
|
+
}
|
|
10393
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10394
|
+
}
|
|
10395
|
+
function scanClassSetSubExpression(expressionType) {
|
|
10396
|
+
let expressionMayContainStrings = mayContainStrings;
|
|
10397
|
+
while (true) {
|
|
10398
|
+
let ch = charCodeChecked(pos);
|
|
10399
|
+
if (isClassContentExit(ch)) {
|
|
10400
|
+
break;
|
|
10401
|
+
}
|
|
10402
|
+
switch (ch) {
|
|
10259
10403
|
case 45 /* minus */:
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10404
|
+
pos++;
|
|
10405
|
+
if (charCodeChecked(pos) === 45 /* minus */) {
|
|
10406
|
+
pos++;
|
|
10407
|
+
if (expressionType !== 3 /* ClassSubtraction */) {
|
|
10408
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10263
10409
|
}
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10267
|
-
return;
|
|
10410
|
+
} else {
|
|
10411
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
|
|
10268
10412
|
}
|
|
10269
10413
|
break;
|
|
10270
10414
|
case 38 /* ampersand */:
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10415
|
+
pos++;
|
|
10416
|
+
if (charCodeChecked(pos) === 38 /* ampersand */) {
|
|
10417
|
+
pos++;
|
|
10418
|
+
if (expressionType !== 2 /* ClassIntersection */) {
|
|
10419
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10420
|
+
}
|
|
10421
|
+
if (charCodeChecked(pos) === 38 /* ampersand */) {
|
|
10422
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10423
|
+
pos++;
|
|
10275
10424
|
}
|
|
10276
|
-
expressionMayContainStrings = mayContainStrings;
|
|
10277
|
-
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10278
|
-
return;
|
|
10279
10425
|
} else {
|
|
10280
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10426
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
10281
10427
|
}
|
|
10282
10428
|
break;
|
|
10283
10429
|
default:
|
|
10284
|
-
|
|
10285
|
-
|
|
10430
|
+
switch (expressionType) {
|
|
10431
|
+
case 3 /* ClassSubtraction */:
|
|
10432
|
+
error(Diagnostics._0_expected, pos, 0, "--");
|
|
10433
|
+
break;
|
|
10434
|
+
case 2 /* ClassIntersection */:
|
|
10435
|
+
error(Diagnostics._0_expected, pos, 0, "&&");
|
|
10436
|
+
break;
|
|
10437
|
+
default:
|
|
10438
|
+
break;
|
|
10286
10439
|
}
|
|
10287
|
-
expressionMayContainStrings = mayContainStrings;
|
|
10288
10440
|
break;
|
|
10289
10441
|
}
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
pos++;
|
|
10295
|
-
ch = text2.charCodeAt(pos);
|
|
10296
|
-
if (isClassContentExit(ch)) {
|
|
10297
|
-
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10298
|
-
return;
|
|
10299
|
-
}
|
|
10300
|
-
if (ch === 45 /* minus */) {
|
|
10301
|
-
pos++;
|
|
10302
|
-
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10303
|
-
start2 = pos - 2;
|
|
10304
|
-
oprand = text2.slice(start2, pos);
|
|
10305
|
-
continue;
|
|
10306
|
-
} else {
|
|
10307
|
-
if (!oprand) {
|
|
10308
|
-
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
|
|
10309
|
-
}
|
|
10310
|
-
const secondStart = pos;
|
|
10311
|
-
const secondOprand = scanClassSetOprand();
|
|
10312
|
-
if (isCharacterComplement && mayContainStrings) {
|
|
10313
|
-
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
|
|
10314
|
-
}
|
|
10315
|
-
expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
|
|
10316
|
-
if (!secondOprand) {
|
|
10317
|
-
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
|
|
10318
|
-
break;
|
|
10319
|
-
}
|
|
10320
|
-
if (!oprand) {
|
|
10321
|
-
break;
|
|
10322
|
-
}
|
|
10323
|
-
const minCharacterValue = codePointAt(oprand, 0);
|
|
10324
|
-
const maxCharacterValue = codePointAt(secondOprand, 0);
|
|
10325
|
-
if (oprand.length === charSize(minCharacterValue) && secondOprand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
10326
|
-
error(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
|
|
10327
|
-
}
|
|
10328
|
-
}
|
|
10329
|
-
break;
|
|
10330
|
-
case 38 /* ampersand */:
|
|
10331
|
-
start2 = pos;
|
|
10332
|
-
pos++;
|
|
10333
|
-
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
10334
|
-
pos++;
|
|
10335
|
-
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10336
|
-
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
10337
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10338
|
-
pos++;
|
|
10339
|
-
}
|
|
10340
|
-
} else {
|
|
10341
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
10342
|
-
}
|
|
10343
|
-
oprand = text2.slice(start2, pos);
|
|
10344
|
-
continue;
|
|
10345
|
-
}
|
|
10346
|
-
if (isClassContentExit(text2.charCodeAt(pos))) {
|
|
10347
|
-
break;
|
|
10348
|
-
}
|
|
10349
|
-
start2 = pos;
|
|
10350
|
-
switch (text2.slice(pos, pos + 2)) {
|
|
10351
|
-
case "--":
|
|
10352
|
-
case "&&":
|
|
10353
|
-
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
|
|
10354
|
-
pos += 2;
|
|
10355
|
-
oprand = text2.slice(start2, pos);
|
|
10356
|
-
break;
|
|
10357
|
-
default:
|
|
10358
|
-
oprand = scanClassSetOprand();
|
|
10359
|
-
break;
|
|
10360
|
-
}
|
|
10442
|
+
ch = charCodeChecked(pos);
|
|
10443
|
+
if (isClassContentExit(ch)) {
|
|
10444
|
+
error(Diagnostics.Expected_a_class_set_operand);
|
|
10445
|
+
break;
|
|
10361
10446
|
}
|
|
10362
|
-
|
|
10447
|
+
scanClassSetOperand();
|
|
10448
|
+
expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
|
|
10363
10449
|
}
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
case 38 /* ampersand */:
|
|
10450
|
+
mayContainStrings = expressionMayContainStrings;
|
|
10451
|
+
}
|
|
10452
|
+
function scanClassSetOperand() {
|
|
10453
|
+
mayContainStrings = false;
|
|
10454
|
+
switch (charCodeChecked(pos)) {
|
|
10455
|
+
case -1 /* EOF */:
|
|
10456
|
+
return "";
|
|
10457
|
+
case 91 /* openBracket */:
|
|
10458
|
+
pos++;
|
|
10459
|
+
scanClassSetExpression();
|
|
10460
|
+
scanExpectedChar(93 /* closeBracket */);
|
|
10461
|
+
return "";
|
|
10462
|
+
case 92 /* backslash */:
|
|
10463
|
+
pos++;
|
|
10464
|
+
if (scanCharacterClassEscape()) {
|
|
10465
|
+
return "";
|
|
10466
|
+
} else if (charCodeChecked(pos) === 113 /* q */) {
|
|
10467
|
+
pos++;
|
|
10468
|
+
if (charCodeChecked(pos) === 123 /* openBrace */) {
|
|
10384
10469
|
pos++;
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
pos++;
|
|
10393
|
-
}
|
|
10394
|
-
} else {
|
|
10395
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
10396
|
-
}
|
|
10397
|
-
break;
|
|
10398
|
-
default:
|
|
10399
|
-
switch (expressionType) {
|
|
10400
|
-
case 3 /* ClassSubtraction */:
|
|
10401
|
-
error(Diagnostics._0_expected, pos, 0, "--");
|
|
10402
|
-
break;
|
|
10403
|
-
case 2 /* ClassIntersection */:
|
|
10404
|
-
error(Diagnostics._0_expected, pos, 0, "&&");
|
|
10405
|
-
break;
|
|
10406
|
-
default:
|
|
10407
|
-
break;
|
|
10408
|
-
}
|
|
10409
|
-
break;
|
|
10470
|
+
scanClassStringDisjunctionContents();
|
|
10471
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
10472
|
+
return "";
|
|
10473
|
+
} else {
|
|
10474
|
+
error(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
|
|
10475
|
+
return "q";
|
|
10476
|
+
}
|
|
10410
10477
|
}
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10478
|
+
pos--;
|
|
10479
|
+
default:
|
|
10480
|
+
return scanClassSetCharacter();
|
|
10481
|
+
}
|
|
10482
|
+
}
|
|
10483
|
+
function scanClassStringDisjunctionContents() {
|
|
10484
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 123 /* openBrace */);
|
|
10485
|
+
let characterCount = 0;
|
|
10486
|
+
while (true) {
|
|
10487
|
+
const ch = charCodeChecked(pos);
|
|
10488
|
+
switch (ch) {
|
|
10489
|
+
case -1 /* EOF */:
|
|
10490
|
+
return;
|
|
10491
|
+
case 125 /* closeBrace */:
|
|
10492
|
+
if (characterCount !== 1) {
|
|
10493
|
+
mayContainStrings = true;
|
|
10494
|
+
}
|
|
10495
|
+
return;
|
|
10496
|
+
case 124 /* bar */:
|
|
10497
|
+
if (characterCount !== 1) {
|
|
10498
|
+
mayContainStrings = true;
|
|
10499
|
+
}
|
|
10500
|
+
pos++;
|
|
10501
|
+
start = pos;
|
|
10502
|
+
characterCount = 0;
|
|
10503
|
+
break;
|
|
10504
|
+
default:
|
|
10505
|
+
scanClassSetCharacter();
|
|
10506
|
+
characterCount++;
|
|
10414
10507
|
break;
|
|
10415
|
-
}
|
|
10416
|
-
scanClassSetOprand();
|
|
10417
|
-
expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
|
|
10418
10508
|
}
|
|
10419
|
-
mayContainStrings = expressionMayContainStrings;
|
|
10420
10509
|
}
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10510
|
+
}
|
|
10511
|
+
function scanClassSetCharacter() {
|
|
10512
|
+
const ch = charCodeChecked(pos);
|
|
10513
|
+
if (ch === -1 /* EOF */) {
|
|
10514
|
+
return "";
|
|
10515
|
+
}
|
|
10516
|
+
if (ch === 92 /* backslash */) {
|
|
10517
|
+
pos++;
|
|
10518
|
+
const ch2 = charCodeChecked(pos);
|
|
10519
|
+
switch (ch2) {
|
|
10520
|
+
case 98 /* b */:
|
|
10425
10521
|
pos++;
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
case
|
|
10522
|
+
return "\b";
|
|
10523
|
+
case 38 /* ampersand */:
|
|
10524
|
+
case 45 /* minus */:
|
|
10525
|
+
case 33 /* exclamation */:
|
|
10526
|
+
case 35 /* hash */:
|
|
10527
|
+
case 37 /* percent */:
|
|
10528
|
+
case 44 /* comma */:
|
|
10529
|
+
case 58 /* colon */:
|
|
10530
|
+
case 59 /* semicolon */:
|
|
10531
|
+
case 60 /* lessThan */:
|
|
10532
|
+
case 61 /* equals */:
|
|
10533
|
+
case 62 /* greaterThan */:
|
|
10534
|
+
case 64 /* at */:
|
|
10535
|
+
case 96 /* backtick */:
|
|
10536
|
+
case 126 /* tilde */:
|
|
10430
10537
|
pos++;
|
|
10431
|
-
|
|
10432
|
-
return "";
|
|
10433
|
-
} else if (text2.charCodeAt(pos) === 113 /* q */) {
|
|
10434
|
-
pos++;
|
|
10435
|
-
if (text2.charCodeAt(pos) === 123 /* openBrace */) {
|
|
10436
|
-
pos++;
|
|
10437
|
-
scanClassStringDisjunctionContents();
|
|
10438
|
-
scanExpectedChar(125 /* closeBrace */);
|
|
10439
|
-
return "";
|
|
10440
|
-
} else {
|
|
10441
|
-
error(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
|
|
10442
|
-
return "q";
|
|
10443
|
-
}
|
|
10444
|
-
}
|
|
10445
|
-
pos--;
|
|
10538
|
+
return String.fromCharCode(ch2);
|
|
10446
10539
|
default:
|
|
10447
|
-
return
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10540
|
+
return scanCharacterEscape(
|
|
10541
|
+
/*atomEscape*/
|
|
10542
|
+
false
|
|
10543
|
+
);
|
|
10544
|
+
}
|
|
10545
|
+
} else if (ch === charCodeChecked(pos + 1)) {
|
|
10546
|
+
switch (ch) {
|
|
10547
|
+
case 38 /* ampersand */:
|
|
10548
|
+
case 33 /* exclamation */:
|
|
10549
|
+
case 35 /* hash */:
|
|
10550
|
+
case 37 /* percent */:
|
|
10551
|
+
case 42 /* asterisk */:
|
|
10552
|
+
case 43 /* plus */:
|
|
10553
|
+
case 44 /* comma */:
|
|
10554
|
+
case 46 /* dot */:
|
|
10555
|
+
case 58 /* colon */:
|
|
10556
|
+
case 59 /* semicolon */:
|
|
10557
|
+
case 60 /* lessThan */:
|
|
10558
|
+
case 61 /* equals */:
|
|
10559
|
+
case 62 /* greaterThan */:
|
|
10560
|
+
case 63 /* question */:
|
|
10561
|
+
case 64 /* at */:
|
|
10562
|
+
case 96 /* backtick */:
|
|
10563
|
+
case 126 /* tilde */:
|
|
10564
|
+
error(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
|
|
10565
|
+
pos += 2;
|
|
10566
|
+
return text.substring(pos - 2, pos);
|
|
10474
10567
|
}
|
|
10475
10568
|
}
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10569
|
+
switch (ch) {
|
|
10570
|
+
case 47 /* slash */:
|
|
10571
|
+
case 40 /* openParen */:
|
|
10572
|
+
case 41 /* closeParen */:
|
|
10573
|
+
case 91 /* openBracket */:
|
|
10574
|
+
case 93 /* closeBracket */:
|
|
10575
|
+
case 123 /* openBrace */:
|
|
10576
|
+
case 125 /* closeBrace */:
|
|
10577
|
+
case 45 /* minus */:
|
|
10578
|
+
case 124 /* bar */:
|
|
10579
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10479
10580
|
pos++;
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
case 35 /* hash */:
|
|
10489
|
-
case 37 /* percent */:
|
|
10490
|
-
case 44 /* comma */:
|
|
10491
|
-
case 58 /* colon */:
|
|
10492
|
-
case 59 /* semicolon */:
|
|
10493
|
-
case 60 /* lessThan */:
|
|
10494
|
-
case 61 /* equals */:
|
|
10495
|
-
case 62 /* greaterThan */:
|
|
10496
|
-
case 64 /* at */:
|
|
10497
|
-
case 96 /* backtick */:
|
|
10498
|
-
case 126 /* tilde */:
|
|
10499
|
-
pos++;
|
|
10500
|
-
return String.fromCharCode(ch2);
|
|
10501
|
-
default:
|
|
10502
|
-
return scanCharacterEscape(
|
|
10503
|
-
/*atomEscape*/
|
|
10504
|
-
false
|
|
10505
|
-
);
|
|
10506
|
-
}
|
|
10507
|
-
} else if (ch === text2.charCodeAt(pos + 1)) {
|
|
10508
|
-
switch (ch) {
|
|
10509
|
-
case 38 /* ampersand */:
|
|
10510
|
-
case 33 /* exclamation */:
|
|
10511
|
-
case 35 /* hash */:
|
|
10512
|
-
case 37 /* percent */:
|
|
10513
|
-
case 42 /* asterisk */:
|
|
10514
|
-
case 43 /* plus */:
|
|
10515
|
-
case 44 /* comma */:
|
|
10516
|
-
case 46 /* dot */:
|
|
10517
|
-
case 58 /* colon */:
|
|
10518
|
-
case 59 /* semicolon */:
|
|
10519
|
-
case 60 /* lessThan */:
|
|
10520
|
-
case 61 /* equals */:
|
|
10521
|
-
case 62 /* greaterThan */:
|
|
10522
|
-
case 63 /* question */:
|
|
10523
|
-
case 64 /* at */:
|
|
10524
|
-
case 96 /* backtick */:
|
|
10525
|
-
case 126 /* tilde */:
|
|
10526
|
-
error(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
|
|
10527
|
-
pos += 2;
|
|
10528
|
-
return text2.substring(pos - 2, pos);
|
|
10529
|
-
}
|
|
10530
|
-
}
|
|
10581
|
+
return String.fromCharCode(ch);
|
|
10582
|
+
}
|
|
10583
|
+
return scanSourceCharacter();
|
|
10584
|
+
}
|
|
10585
|
+
function scanClassAtom() {
|
|
10586
|
+
if (charCodeChecked(pos) === 92 /* backslash */) {
|
|
10587
|
+
pos++;
|
|
10588
|
+
const ch = charCodeChecked(pos);
|
|
10531
10589
|
switch (ch) {
|
|
10532
|
-
case
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
case 91 /* openBracket */:
|
|
10536
|
-
case 93 /* closeBracket */:
|
|
10537
|
-
case 123 /* openBrace */:
|
|
10538
|
-
case 125 /* closeBrace */:
|
|
10590
|
+
case 98 /* b */:
|
|
10591
|
+
pos++;
|
|
10592
|
+
return "\b";
|
|
10539
10593
|
case 45 /* minus */:
|
|
10540
|
-
case 124 /* bar */:
|
|
10541
|
-
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10542
10594
|
pos++;
|
|
10543
10595
|
return String.fromCharCode(ch);
|
|
10596
|
+
default:
|
|
10597
|
+
if (scanCharacterClassEscape()) {
|
|
10598
|
+
return "";
|
|
10599
|
+
}
|
|
10600
|
+
return scanCharacterEscape(
|
|
10601
|
+
/*atomEscape*/
|
|
10602
|
+
false
|
|
10603
|
+
);
|
|
10544
10604
|
}
|
|
10605
|
+
} else {
|
|
10545
10606
|
return scanSourceCharacter();
|
|
10546
10607
|
}
|
|
10547
|
-
|
|
10548
|
-
|
|
10608
|
+
}
|
|
10609
|
+
function scanCharacterClassEscape() {
|
|
10610
|
+
Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
|
|
10611
|
+
let isCharacterComplement = false;
|
|
10612
|
+
const start2 = pos - 1;
|
|
10613
|
+
const ch = charCodeChecked(pos);
|
|
10614
|
+
switch (ch) {
|
|
10615
|
+
case 100 /* d */:
|
|
10616
|
+
case 68 /* D */:
|
|
10617
|
+
case 115 /* s */:
|
|
10618
|
+
case 83 /* S */:
|
|
10619
|
+
case 119 /* w */:
|
|
10620
|
+
case 87 /* W */:
|
|
10549
10621
|
pos++;
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
pos++;
|
|
10557
|
-
return String.fromCharCode(ch);
|
|
10558
|
-
default:
|
|
10559
|
-
if (scanCharacterClassEscape()) {
|
|
10560
|
-
return "";
|
|
10561
|
-
}
|
|
10562
|
-
return scanCharacterEscape(
|
|
10563
|
-
/*atomEscape*/
|
|
10564
|
-
false
|
|
10565
|
-
);
|
|
10566
|
-
}
|
|
10567
|
-
} else {
|
|
10568
|
-
return scanSourceCharacter();
|
|
10569
|
-
}
|
|
10570
|
-
}
|
|
10571
|
-
function scanCharacterClassEscape() {
|
|
10572
|
-
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10573
|
-
let isCharacterComplement = false;
|
|
10574
|
-
const start2 = pos - 1;
|
|
10575
|
-
const ch = text2.charCodeAt(pos);
|
|
10576
|
-
switch (ch) {
|
|
10577
|
-
case 100 /* d */:
|
|
10578
|
-
case 68 /* D */:
|
|
10579
|
-
case 115 /* s */:
|
|
10580
|
-
case 83 /* S */:
|
|
10581
|
-
case 119 /* w */:
|
|
10582
|
-
case 87 /* W */:
|
|
10583
|
-
pos++;
|
|
10584
|
-
return true;
|
|
10585
|
-
case 80 /* P */:
|
|
10586
|
-
isCharacterComplement = true;
|
|
10587
|
-
case 112 /* p */:
|
|
10622
|
+
return true;
|
|
10623
|
+
case 80 /* P */:
|
|
10624
|
+
isCharacterComplement = true;
|
|
10625
|
+
case 112 /* p */:
|
|
10626
|
+
pos++;
|
|
10627
|
+
if (charCodeChecked(pos) === 123 /* openBrace */) {
|
|
10588
10628
|
pos++;
|
|
10589
|
-
|
|
10629
|
+
const propertyNameOrValueStart = pos;
|
|
10630
|
+
const propertyNameOrValue = scanWordCharacters();
|
|
10631
|
+
if (charCodeChecked(pos) === 61 /* equals */) {
|
|
10632
|
+
const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
|
|
10633
|
+
if (pos === propertyNameOrValueStart) {
|
|
10634
|
+
error(Diagnostics.Expected_a_Unicode_property_name);
|
|
10635
|
+
} else if (propertyName === void 0) {
|
|
10636
|
+
error(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10637
|
+
const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
|
|
10638
|
+
if (suggestion) {
|
|
10639
|
+
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
10640
|
+
}
|
|
10641
|
+
}
|
|
10590
10642
|
pos++;
|
|
10591
|
-
const
|
|
10592
|
-
const
|
|
10593
|
-
if (
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
if (suggestion) {
|
|
10601
|
-
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
10602
|
-
}
|
|
10643
|
+
const propertyValueStart = pos;
|
|
10644
|
+
const propertyValue = scanWordCharacters();
|
|
10645
|
+
if (pos === propertyValueStart) {
|
|
10646
|
+
error(Diagnostics.Expected_a_Unicode_property_value);
|
|
10647
|
+
} else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
|
|
10648
|
+
error(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
|
|
10649
|
+
const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
|
|
10650
|
+
if (suggestion) {
|
|
10651
|
+
error(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
|
|
10603
10652
|
}
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
error(Diagnostics.
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10653
|
+
}
|
|
10654
|
+
} else {
|
|
10655
|
+
if (pos === propertyNameOrValueStart) {
|
|
10656
|
+
error(Diagnostics.Expected_a_Unicode_property_name_or_value);
|
|
10657
|
+
} else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
|
|
10658
|
+
if (!unicodeSetsMode) {
|
|
10659
|
+
error(Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10660
|
+
} else if (isCharacterComplement) {
|
|
10661
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10662
|
+
} else {
|
|
10663
|
+
mayContainStrings = true;
|
|
10615
10664
|
}
|
|
10616
|
-
} else {
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
error(Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10622
|
-
} else if (isCharacterComplement) {
|
|
10623
|
-
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10624
|
-
} else {
|
|
10625
|
-
mayContainStrings = true;
|
|
10626
|
-
}
|
|
10627
|
-
} else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
|
|
10628
|
-
error(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10629
|
-
const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
|
|
10630
|
-
if (suggestion) {
|
|
10631
|
-
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
10632
|
-
}
|
|
10665
|
+
} else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
|
|
10666
|
+
error(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10667
|
+
const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
|
|
10668
|
+
if (suggestion) {
|
|
10669
|
+
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
10633
10670
|
}
|
|
10634
10671
|
}
|
|
10635
|
-
scanExpectedChar(125 /* closeBrace */);
|
|
10636
|
-
if (!unicodeMode) {
|
|
10637
|
-
error(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
|
|
10638
|
-
}
|
|
10639
|
-
} else if (unicodeMode) {
|
|
10640
|
-
error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
|
|
10641
10672
|
}
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
while (pos < end2) {
|
|
10649
|
-
const ch = text2.charCodeAt(pos);
|
|
10650
|
-
if (!isWordCharacter(ch)) {
|
|
10651
|
-
break;
|
|
10673
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
10674
|
+
if (!unicodeMode) {
|
|
10675
|
+
error(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
|
|
10676
|
+
}
|
|
10677
|
+
} else if (unicodeMode) {
|
|
10678
|
+
error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
|
|
10652
10679
|
}
|
|
10653
|
-
|
|
10654
|
-
|
|
10680
|
+
return true;
|
|
10681
|
+
}
|
|
10682
|
+
return false;
|
|
10683
|
+
}
|
|
10684
|
+
function scanWordCharacters() {
|
|
10685
|
+
let value = "";
|
|
10686
|
+
while (true) {
|
|
10687
|
+
const ch = charCodeChecked(pos);
|
|
10688
|
+
if (ch === -1 /* EOF */ || !isWordCharacter(ch)) {
|
|
10689
|
+
break;
|
|
10655
10690
|
}
|
|
10656
|
-
|
|
10691
|
+
value += String.fromCharCode(ch);
|
|
10692
|
+
pos++;
|
|
10657
10693
|
}
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10694
|
+
return value;
|
|
10695
|
+
}
|
|
10696
|
+
function scanSourceCharacter() {
|
|
10697
|
+
const size = unicodeMode ? charSize(charCodeChecked(pos)) : 1;
|
|
10698
|
+
pos += size;
|
|
10699
|
+
return size > 0 ? text.substring(pos - size, pos) : "";
|
|
10700
|
+
}
|
|
10701
|
+
function scanExpectedChar(ch) {
|
|
10702
|
+
if (charCodeChecked(pos) === ch) {
|
|
10703
|
+
pos++;
|
|
10704
|
+
} else {
|
|
10705
|
+
error(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
|
|
10662
10706
|
}
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10707
|
+
}
|
|
10708
|
+
scanDisjunction(
|
|
10709
|
+
/*isInGroup*/
|
|
10710
|
+
false
|
|
10711
|
+
);
|
|
10712
|
+
forEach(groupNameReferences, (reference) => {
|
|
10713
|
+
if (!(groupSpecifiers == null ? void 0 : groupSpecifiers.has(reference.name))) {
|
|
10714
|
+
error(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
|
|
10669
10715
|
}
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
error(Diagnostics.
|
|
10677
|
-
}
|
|
10678
|
-
});
|
|
10679
|
-
forEach(decimalEscapes, (escape) => {
|
|
10680
|
-
if (!annexB && escape.value > numberOfCapturingGroups) {
|
|
10681
|
-
if (numberOfCapturingGroups) {
|
|
10682
|
-
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);
|
|
10683
|
-
} else {
|
|
10684
|
-
error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
|
|
10685
|
-
}
|
|
10716
|
+
});
|
|
10717
|
+
forEach(decimalEscapes, (escape) => {
|
|
10718
|
+
if (!annexB && escape.value > numberOfCapturingGroups) {
|
|
10719
|
+
if (numberOfCapturingGroups) {
|
|
10720
|
+
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);
|
|
10721
|
+
} else {
|
|
10722
|
+
error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
|
|
10686
10723
|
}
|
|
10687
|
-
});
|
|
10688
|
-
}
|
|
10689
|
-
function checkRegularExpressionFlagAvailable(flag, pos2) {
|
|
10690
|
-
const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
|
|
10691
|
-
if (availableFrom && languageVersion < availableFrom) {
|
|
10692
|
-
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
|
|
10693
10724
|
}
|
|
10725
|
+
});
|
|
10726
|
+
}
|
|
10727
|
+
function checkRegularExpressionFlagAvailable(flag, pos2) {
|
|
10728
|
+
const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
|
|
10729
|
+
if (availableFrom && languageVersion < availableFrom) {
|
|
10730
|
+
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
|
|
10694
10731
|
}
|
|
10695
10732
|
}
|
|
10696
10733
|
function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
|
|
@@ -10758,9 +10795,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10758
10795
|
if (pos >= end) {
|
|
10759
10796
|
return token = 1 /* EndOfFileToken */;
|
|
10760
10797
|
}
|
|
10761
|
-
let char =
|
|
10798
|
+
let char = charCodeUnchecked(pos);
|
|
10762
10799
|
if (char === 60 /* lessThan */) {
|
|
10763
|
-
if (
|
|
10800
|
+
if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
|
|
10764
10801
|
pos += 2;
|
|
10765
10802
|
return token = 31 /* LessThanSlashToken */;
|
|
10766
10803
|
}
|
|
@@ -10773,7 +10810,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10773
10810
|
}
|
|
10774
10811
|
let firstNonWhitespace = 0;
|
|
10775
10812
|
while (pos < end) {
|
|
10776
|
-
char =
|
|
10813
|
+
char = charCodeUnchecked(pos);
|
|
10777
10814
|
if (char === 123 /* openBrace */) {
|
|
10778
10815
|
break;
|
|
10779
10816
|
}
|
|
@@ -10805,7 +10842,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10805
10842
|
function scanJsxIdentifier() {
|
|
10806
10843
|
if (tokenIsIdentifierOrKeyword(token)) {
|
|
10807
10844
|
while (pos < end) {
|
|
10808
|
-
const ch =
|
|
10845
|
+
const ch = charCodeUnchecked(pos);
|
|
10809
10846
|
if (ch === 45 /* minus */) {
|
|
10810
10847
|
tokenValue += "-";
|
|
10811
10848
|
pos++;
|
|
@@ -10823,7 +10860,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10823
10860
|
}
|
|
10824
10861
|
function scanJsxAttributeValue() {
|
|
10825
10862
|
fullStartPos = pos;
|
|
10826
|
-
switch (
|
|
10863
|
+
switch (charCodeUnchecked(pos)) {
|
|
10827
10864
|
case 34 /* doubleQuote */:
|
|
10828
10865
|
case 39 /* singleQuote */:
|
|
10829
10866
|
tokenValue = scanString(
|
|
@@ -10845,11 +10882,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10845
10882
|
if (pos >= end) {
|
|
10846
10883
|
return token = 1 /* EndOfFileToken */;
|
|
10847
10884
|
}
|
|
10848
|
-
for (let ch =
|
|
10885
|
+
for (let ch = charCodeUnchecked(pos); pos < end && (!isLineBreak(ch) && ch !== 96 /* backtick */); ch = codePointUnchecked(++pos)) {
|
|
10849
10886
|
if (!inBackticks) {
|
|
10850
10887
|
if (ch === 123 /* openBrace */) {
|
|
10851
10888
|
break;
|
|
10852
|
-
} else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(
|
|
10889
|
+
} else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(charCodeUnchecked(pos - 1)) && !(pos + 1 < end && isWhiteSpaceLike(charCodeUnchecked(pos + 1)))) {
|
|
10853
10890
|
break;
|
|
10854
10891
|
}
|
|
10855
10892
|
}
|
|
@@ -10866,21 +10903,21 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10866
10903
|
if (pos >= end) {
|
|
10867
10904
|
return token = 1 /* EndOfFileToken */;
|
|
10868
10905
|
}
|
|
10869
|
-
const ch =
|
|
10906
|
+
const ch = codePointUnchecked(pos);
|
|
10870
10907
|
pos += charSize(ch);
|
|
10871
10908
|
switch (ch) {
|
|
10872
10909
|
case 9 /* tab */:
|
|
10873
10910
|
case 11 /* verticalTab */:
|
|
10874
10911
|
case 12 /* formFeed */:
|
|
10875
10912
|
case 32 /* space */:
|
|
10876
|
-
while (pos < end && isWhiteSpaceSingleLine(
|
|
10913
|
+
while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
|
|
10877
10914
|
pos++;
|
|
10878
10915
|
}
|
|
10879
10916
|
return token = 5 /* WhitespaceTrivia */;
|
|
10880
10917
|
case 64 /* at */:
|
|
10881
10918
|
return token = 60 /* AtToken */;
|
|
10882
10919
|
case 13 /* carriageReturn */:
|
|
10883
|
-
if (
|
|
10920
|
+
if (charCodeUnchecked(pos) === 10 /* lineFeed */) {
|
|
10884
10921
|
pos++;
|
|
10885
10922
|
}
|
|
10886
10923
|
case 10 /* lineFeed */:
|
|
@@ -10936,7 +10973,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
10936
10973
|
}
|
|
10937
10974
|
if (isIdentifierStart(ch, languageVersion)) {
|
|
10938
10975
|
let char = ch;
|
|
10939
|
-
while (pos < end && isIdentifierPart(char =
|
|
10976
|
+
while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === 45 /* minus */)
|
|
10940
10977
|
pos += charSize(char);
|
|
10941
10978
|
tokenValue = text.substring(tokenStart, pos);
|
|
10942
10979
|
if (char === 92 /* backslash */) {
|
|
@@ -11046,6 +11083,9 @@ function charSize(ch) {
|
|
|
11046
11083
|
if (ch >= 65536) {
|
|
11047
11084
|
return 2;
|
|
11048
11085
|
}
|
|
11086
|
+
if (ch === -1 /* EOF */) {
|
|
11087
|
+
return 0;
|
|
11088
|
+
}
|
|
11049
11089
|
return 1;
|
|
11050
11090
|
}
|
|
11051
11091
|
function utf16EncodeAsStringFallback(codePoint) {
|
|
@@ -44084,7 +44124,7 @@ function createBinder() {
|
|
|
44084
44124
|
const reportError = (
|
|
44085
44125
|
// report error on all statements except empty ones
|
|
44086
44126
|
isStatementButNotDeclaration(node) && node.kind !== 242 /* EmptyStatement */ || // report error on class declarations
|
|
44087
|
-
node.kind === 263 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
|
|
44127
|
+
node.kind === 263 /* ClassDeclaration */ || node.kind === 266 /* EnumDeclaration */ && (!isEnumConst(node) || shouldPreserveConstEnums(options)) || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
|
|
44088
44128
|
node.kind === 267 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
|
|
44089
44129
|
);
|
|
44090
44130
|
if (reportError) {
|
|
@@ -45523,6 +45563,7 @@ function createTypeChecker(host) {
|
|
|
45523
45563
|
getBaseTypes,
|
|
45524
45564
|
getBaseTypeOfLiteralType,
|
|
45525
45565
|
getWidenedType,
|
|
45566
|
+
getWidenedLiteralType,
|
|
45526
45567
|
getTypeFromTypeNode: (nodeIn) => {
|
|
45527
45568
|
const node = getParseTreeNode(nodeIn, isTypeNode);
|
|
45528
45569
|
return node ? getTypeFromTypeNode(node) : errorType;
|
|
@@ -48100,12 +48141,6 @@ function createTypeChecker(host) {
|
|
|
48100
48141
|
}
|
|
48101
48142
|
}
|
|
48102
48143
|
}
|
|
48103
|
-
function markConstEnumAliasAsReferenced(symbol) {
|
|
48104
|
-
const links = getSymbolLinks(symbol);
|
|
48105
|
-
if (!links.constEnumReferenced) {
|
|
48106
|
-
links.constEnumReferenced = true;
|
|
48107
|
-
}
|
|
48108
|
-
}
|
|
48109
48144
|
function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
|
|
48110
48145
|
if (entityName.kind === 80 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
|
|
48111
48146
|
entityName = entityName.parent;
|
|
@@ -54807,7 +54842,7 @@ function createTypeChecker(host) {
|
|
|
54807
54842
|
}
|
|
54808
54843
|
type = anyType;
|
|
54809
54844
|
}
|
|
54810
|
-
links.type = type;
|
|
54845
|
+
links.type ?? (links.type = type);
|
|
54811
54846
|
}
|
|
54812
54847
|
return links.type;
|
|
54813
54848
|
}
|
|
@@ -54825,7 +54860,7 @@ function createTypeChecker(host) {
|
|
|
54825
54860
|
}
|
|
54826
54861
|
writeType = anyType;
|
|
54827
54862
|
}
|
|
54828
|
-
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
54863
|
+
links.writeType ?? (links.writeType = writeType || getTypeOfAccessors(symbol));
|
|
54829
54864
|
}
|
|
54830
54865
|
return links.writeType;
|
|
54831
54866
|
}
|
|
@@ -54902,10 +54937,10 @@ function createTypeChecker(host) {
|
|
|
54902
54937
|
true
|
|
54903
54938
|
);
|
|
54904
54939
|
const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0);
|
|
54905
|
-
links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType;
|
|
54940
|
+
links.type ?? (links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType);
|
|
54906
54941
|
if (!popTypeResolution()) {
|
|
54907
54942
|
reportCircularityError(exportSymbol ?? symbol);
|
|
54908
|
-
return links.type = errorType;
|
|
54943
|
+
return links.type ?? (links.type = errorType);
|
|
54909
54944
|
}
|
|
54910
54945
|
}
|
|
54911
54946
|
return links.type;
|
|
@@ -55171,7 +55206,7 @@ function createTypeChecker(host) {
|
|
|
55171
55206
|
}
|
|
55172
55207
|
if (!popTypeResolution()) {
|
|
55173
55208
|
error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
|
|
55174
|
-
return type.resolvedBaseConstructorType = errorType;
|
|
55209
|
+
return type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = errorType);
|
|
55175
55210
|
}
|
|
55176
55211
|
if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
|
|
55177
55212
|
const err = error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
|
|
@@ -55188,9 +55223,9 @@ function createTypeChecker(host) {
|
|
|
55188
55223
|
addRelatedInfo(err, createDiagnosticForNode(baseConstructorType.symbol.declarations[0], Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn)));
|
|
55189
55224
|
}
|
|
55190
55225
|
}
|
|
55191
|
-
return type.resolvedBaseConstructorType = errorType;
|
|
55226
|
+
return type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = errorType);
|
|
55192
55227
|
}
|
|
55193
|
-
type.resolvedBaseConstructorType = baseConstructorType;
|
|
55228
|
+
type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = baseConstructorType);
|
|
55194
55229
|
}
|
|
55195
55230
|
return type.resolvedBaseConstructorType;
|
|
55196
55231
|
}
|
|
@@ -55431,7 +55466,7 @@ function createTypeChecker(host) {
|
|
|
55431
55466
|
error(isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
55432
55467
|
}
|
|
55433
55468
|
}
|
|
55434
|
-
links.declaredType = type;
|
|
55469
|
+
links.declaredType ?? (links.declaredType = type);
|
|
55435
55470
|
}
|
|
55436
55471
|
return links.declaredType;
|
|
55437
55472
|
}
|
|
@@ -56549,6 +56584,7 @@ function createTypeChecker(host) {
|
|
|
56549
56584
|
}
|
|
56550
56585
|
}
|
|
56551
56586
|
function getTypeOfMappedSymbol(symbol) {
|
|
56587
|
+
var _a;
|
|
56552
56588
|
if (!symbol.links.type) {
|
|
56553
56589
|
const mappedType = symbol.links.mappedType;
|
|
56554
56590
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
@@ -56567,7 +56603,7 @@ function createTypeChecker(host) {
|
|
|
56567
56603
|
error(currentNode, Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
|
|
56568
56604
|
type = errorType;
|
|
56569
56605
|
}
|
|
56570
|
-
symbol.links.type = type;
|
|
56606
|
+
(_a = symbol.links).type ?? (_a.type = type);
|
|
56571
56607
|
}
|
|
56572
56608
|
return symbol.links.type;
|
|
56573
56609
|
}
|
|
@@ -56920,7 +56956,7 @@ function createTypeChecker(host) {
|
|
|
56920
56956
|
}
|
|
56921
56957
|
result = circularConstraintType;
|
|
56922
56958
|
}
|
|
56923
|
-
t.immediateBaseConstraint = result || noConstraintType;
|
|
56959
|
+
t.immediateBaseConstraint ?? (t.immediateBaseConstraint = result || noConstraintType);
|
|
56924
56960
|
}
|
|
56925
56961
|
return t.immediateBaseConstraint;
|
|
56926
56962
|
}
|
|
@@ -57794,7 +57830,7 @@ function createTypeChecker(host) {
|
|
|
57794
57830
|
}
|
|
57795
57831
|
type = anyType;
|
|
57796
57832
|
}
|
|
57797
|
-
signature.resolvedReturnType = type;
|
|
57833
|
+
signature.resolvedReturnType ?? (signature.resolvedReturnType = type);
|
|
57798
57834
|
}
|
|
57799
57835
|
return signature.resolvedReturnType;
|
|
57800
57836
|
}
|
|
@@ -58140,9 +58176,9 @@ function createTypeChecker(host) {
|
|
|
58140
58176
|
const node = type.node;
|
|
58141
58177
|
const typeArguments = !node ? emptyArray : node.kind === 183 /* TypeReference */ ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : node.kind === 188 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : map(node.elements, getTypeFromTypeNode);
|
|
58142
58178
|
if (popTypeResolution()) {
|
|
58143
|
-
type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
|
|
58179
|
+
type.resolvedTypeArguments ?? (type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments);
|
|
58144
58180
|
} else {
|
|
58145
|
-
type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray;
|
|
58181
|
+
type.resolvedTypeArguments ?? (type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray);
|
|
58146
58182
|
error(
|
|
58147
58183
|
type.node || currentNode,
|
|
58148
58184
|
type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
|
|
@@ -65199,6 +65235,7 @@ function createTypeChecker(host) {
|
|
|
65199
65235
|
if (!links.variances) {
|
|
65200
65236
|
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
65201
65237
|
const oldVarianceComputation = inVarianceComputation;
|
|
65238
|
+
const saveResolutionStart = resolutionStart;
|
|
65202
65239
|
if (!inVarianceComputation) {
|
|
65203
65240
|
inVarianceComputation = true;
|
|
65204
65241
|
resolutionStart = resolutionTargets.length;
|
|
@@ -65233,7 +65270,7 @@ function createTypeChecker(host) {
|
|
|
65233
65270
|
}
|
|
65234
65271
|
if (!oldVarianceComputation) {
|
|
65235
65272
|
inVarianceComputation = false;
|
|
65236
|
-
resolutionStart =
|
|
65273
|
+
resolutionStart = saveResolutionStart;
|
|
65237
65274
|
}
|
|
65238
65275
|
links.variances = variances;
|
|
65239
65276
|
(_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
|
|
@@ -69426,7 +69463,7 @@ function createTypeChecker(host) {
|
|
|
69426
69463
|
reportCircularityError(declaration.symbol);
|
|
69427
69464
|
return true;
|
|
69428
69465
|
}
|
|
69429
|
-
links.parameterInitializerContainsUndefined = containsUndefined;
|
|
69466
|
+
links.parameterInitializerContainsUndefined ?? (links.parameterInitializerContainsUndefined = containsUndefined);
|
|
69430
69467
|
}
|
|
69431
69468
|
return links.parameterInitializerContainsUndefined;
|
|
69432
69469
|
}
|
|
@@ -69488,8 +69525,6 @@ function createTypeChecker(host) {
|
|
|
69488
69525
|
) & (111551 /* Value */ | 1048576 /* ExportValue */)) {
|
|
69489
69526
|
if (getIsolatedModules(compilerOptions) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
|
|
69490
69527
|
markAliasSymbolAsReferenced(symbol);
|
|
69491
|
-
} else {
|
|
69492
|
-
markConstEnumAliasAsReferenced(symbol);
|
|
69493
69528
|
}
|
|
69494
69529
|
}
|
|
69495
69530
|
}
|
|
@@ -70746,60 +70781,71 @@ function createTypeChecker(host) {
|
|
|
70746
70781
|
return false;
|
|
70747
70782
|
}
|
|
70748
70783
|
function discriminateContextualTypeByObjectMembers(node, contextualType) {
|
|
70749
|
-
|
|
70750
|
-
|
|
70751
|
-
|
|
70752
|
-
|
|
70753
|
-
|
|
70754
|
-
|
|
70784
|
+
const key = `D${getNodeId(node)},${getTypeId(contextualType)}`;
|
|
70785
|
+
return getCachedType(key) ?? setCachedType(
|
|
70786
|
+
key,
|
|
70787
|
+
getMatchingUnionConstituentForObjectLiteral(contextualType, node) ?? discriminateTypeByDiscriminableItems(
|
|
70788
|
+
contextualType,
|
|
70789
|
+
concatenate(
|
|
70790
|
+
map(
|
|
70791
|
+
filter(node.properties, (p) => {
|
|
70792
|
+
if (!p.symbol) {
|
|
70793
|
+
return false;
|
|
70794
|
+
}
|
|
70795
|
+
if (p.kind === 303 /* PropertyAssignment */) {
|
|
70796
|
+
return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
|
|
70797
|
+
}
|
|
70798
|
+
if (p.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
70799
|
+
return isDiscriminantProperty(contextualType, p.symbol.escapedName);
|
|
70800
|
+
}
|
|
70755
70801
|
return false;
|
|
70756
|
-
}
|
|
70757
|
-
|
|
70758
|
-
|
|
70759
|
-
|
|
70760
|
-
|
|
70761
|
-
|
|
70762
|
-
|
|
70763
|
-
|
|
70764
|
-
|
|
70765
|
-
|
|
70802
|
+
}),
|
|
70803
|
+
(prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
|
|
70804
|
+
),
|
|
70805
|
+
map(
|
|
70806
|
+
filter(getPropertiesOfType(contextualType), (s) => {
|
|
70807
|
+
var _a;
|
|
70808
|
+
return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
|
|
70809
|
+
}),
|
|
70810
|
+
(s) => [() => undefinedType, s.escapedName]
|
|
70811
|
+
)
|
|
70766
70812
|
),
|
|
70767
|
-
|
|
70768
|
-
|
|
70769
|
-
var _a;
|
|
70770
|
-
return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
|
|
70771
|
-
}),
|
|
70772
|
-
(s) => [() => undefinedType, s.escapedName]
|
|
70773
|
-
)
|
|
70774
|
-
),
|
|
70775
|
-
isTypeAssignableTo
|
|
70813
|
+
isTypeAssignableTo
|
|
70814
|
+
)
|
|
70776
70815
|
);
|
|
70777
70816
|
}
|
|
70778
70817
|
function discriminateContextualTypeByJSXAttributes(node, contextualType) {
|
|
70818
|
+
const key = `D${getNodeId(node)},${getTypeId(contextualType)}`;
|
|
70819
|
+
const cached = getCachedType(key);
|
|
70820
|
+
if (cached)
|
|
70821
|
+
return cached;
|
|
70779
70822
|
const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
|
|
70780
|
-
return
|
|
70781
|
-
|
|
70782
|
-
|
|
70783
|
-
|
|
70784
|
-
|
|
70785
|
-
(
|
|
70823
|
+
return setCachedType(
|
|
70824
|
+
key,
|
|
70825
|
+
discriminateTypeByDiscriminableItems(
|
|
70826
|
+
contextualType,
|
|
70827
|
+
concatenate(
|
|
70828
|
+
map(
|
|
70829
|
+
filter(node.properties, (p) => !!p.symbol && p.kind === 291 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer))),
|
|
70830
|
+
(prop) => [!prop.initializer ? () => trueType : () => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
|
|
70831
|
+
),
|
|
70832
|
+
map(
|
|
70833
|
+
filter(getPropertiesOfType(contextualType), (s) => {
|
|
70834
|
+
var _a;
|
|
70835
|
+
if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
|
|
70836
|
+
return false;
|
|
70837
|
+
}
|
|
70838
|
+
const element = node.parent.parent;
|
|
70839
|
+
if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
|
|
70840
|
+
return false;
|
|
70841
|
+
}
|
|
70842
|
+
return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
|
|
70843
|
+
}),
|
|
70844
|
+
(s) => [() => undefinedType, s.escapedName]
|
|
70845
|
+
)
|
|
70786
70846
|
),
|
|
70787
|
-
|
|
70788
|
-
|
|
70789
|
-
var _a;
|
|
70790
|
-
if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
|
|
70791
|
-
return false;
|
|
70792
|
-
}
|
|
70793
|
-
const element = node.parent.parent;
|
|
70794
|
-
if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
|
|
70795
|
-
return false;
|
|
70796
|
-
}
|
|
70797
|
-
return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
|
|
70798
|
-
}),
|
|
70799
|
-
(s) => [() => undefinedType, s.escapedName]
|
|
70800
|
-
)
|
|
70801
|
-
),
|
|
70802
|
-
isTypeAssignableTo
|
|
70847
|
+
isTypeAssignableTo
|
|
70848
|
+
)
|
|
70803
70849
|
);
|
|
70804
70850
|
}
|
|
70805
70851
|
function getApparentTypeOfContextualType(node, contextFlags) {
|
|
@@ -71233,7 +71279,7 @@ function createTypeChecker(host) {
|
|
|
71233
71279
|
}
|
|
71234
71280
|
function checkGrammarRegularExpressionLiteral(node) {
|
|
71235
71281
|
const sourceFile = getSourceFileOfNode(node);
|
|
71236
|
-
if (!hasParseDiagnostics(sourceFile)) {
|
|
71282
|
+
if (!hasParseDiagnostics(sourceFile) && !node.isUnterminated) {
|
|
71237
71283
|
let lastError;
|
|
71238
71284
|
scanner ?? (scanner = createScanner(
|
|
71239
71285
|
99 /* ESNext */,
|
|
@@ -74835,8 +74881,13 @@ function createTypeChecker(host) {
|
|
|
74835
74881
|
if (cached && cached !== resolvingSignature && !candidatesOutArray) {
|
|
74836
74882
|
return cached;
|
|
74837
74883
|
}
|
|
74884
|
+
const saveResolutionStart = resolutionStart;
|
|
74885
|
+
if (!cached) {
|
|
74886
|
+
resolutionStart = resolutionTargets.length;
|
|
74887
|
+
}
|
|
74838
74888
|
links.resolvedSignature = resolvingSignature;
|
|
74839
74889
|
let result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
|
|
74890
|
+
resolutionStart = saveResolutionStart;
|
|
74840
74891
|
if (result !== resolvingSignature) {
|
|
74841
74892
|
if (links.resolvedSignature !== resolvingSignature) {
|
|
74842
74893
|
result = links.resolvedSignature;
|
|
@@ -118968,6 +119019,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118968
119019
|
const createProgramOptions = isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
|
|
118969
119020
|
const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion: typeScriptVersion2 } = createProgramOptions;
|
|
118970
119021
|
let { oldProgram } = createProgramOptions;
|
|
119022
|
+
const reportInvalidIgnoreDeprecations = memoize(() => createOptionValueDiagnostic("ignoreDeprecations", Diagnostics.Invalid_value_for_ignoreDeprecations));
|
|
118971
119023
|
let processingDefaultLibFiles;
|
|
118972
119024
|
let processingOtherFiles;
|
|
118973
119025
|
let files;
|
|
@@ -119254,7 +119306,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119254
119306
|
resolvedLibProcessing = void 0;
|
|
119255
119307
|
resolvedModulesProcessing = void 0;
|
|
119256
119308
|
resolvedTypeReferenceDirectiveNamesProcessing = void 0;
|
|
119257
|
-
let ignoreDeprecationsVersion;
|
|
119258
119309
|
const program = {
|
|
119259
119310
|
getRootFileNames: () => rootNames,
|
|
119260
119311
|
getSourceFile,
|
|
@@ -121506,26 +121557,22 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121506
121557
|
}
|
|
121507
121558
|
}
|
|
121508
121559
|
function getIgnoreDeprecationsVersion() {
|
|
121509
|
-
|
|
121510
|
-
|
|
121511
|
-
|
|
121512
|
-
|
|
121513
|
-
if (ignoreDeprecations === "5.0") {
|
|
121514
|
-
ignoreDeprecationsVersion = new Version(ignoreDeprecations);
|
|
121515
|
-
} else {
|
|
121516
|
-
createOptionValueDiagnostic("ignoreDeprecations", Diagnostics.Invalid_value_for_ignoreDeprecations);
|
|
121517
|
-
}
|
|
121560
|
+
const ignoreDeprecations = options.ignoreDeprecations;
|
|
121561
|
+
if (ignoreDeprecations) {
|
|
121562
|
+
if (ignoreDeprecations === "5.0") {
|
|
121563
|
+
return new Version(ignoreDeprecations);
|
|
121518
121564
|
}
|
|
121565
|
+
reportInvalidIgnoreDeprecations();
|
|
121519
121566
|
}
|
|
121520
|
-
return
|
|
121567
|
+
return Version.zero;
|
|
121521
121568
|
}
|
|
121522
121569
|
function checkDeprecations(deprecatedIn, removedIn, createDiagnostic, fn) {
|
|
121523
121570
|
const deprecatedInVersion = new Version(deprecatedIn);
|
|
121524
121571
|
const removedInVersion = new Version(removedIn);
|
|
121525
121572
|
const typescriptVersion = new Version(typeScriptVersion2 || versionMajorMinor);
|
|
121526
|
-
const
|
|
121573
|
+
const ignoreDeprecationsVersion = getIgnoreDeprecationsVersion();
|
|
121527
121574
|
const mustBeRemoved = !(removedInVersion.compareTo(typescriptVersion) === 1 /* GreaterThan */);
|
|
121528
|
-
const canBeSilenced = !mustBeRemoved &&
|
|
121575
|
+
const canBeSilenced = !mustBeRemoved && ignoreDeprecationsVersion.compareTo(deprecatedInVersion) === -1 /* LessThan */;
|
|
121529
121576
|
if (mustBeRemoved || canBeSilenced) {
|
|
121530
121577
|
fn((name, value, useInstead) => {
|
|
121531
121578
|
if (mustBeRemoved) {
|