typescript 5.1.0-dev.20230324 → 5.1.0-dev.20230325

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/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230324`;
38
+ version = `${versionMajorMinor}.0-dev.20230325`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4040,9 +4040,15 @@ ${lanes.join("\n")}
4040
4040
  TokenFlags2[TokenFlags2["ContainsSeparator"] = 512] = "ContainsSeparator";
4041
4041
  TokenFlags2[TokenFlags2["UnicodeEscape"] = 1024] = "UnicodeEscape";
4042
4042
  TokenFlags2[TokenFlags2["ContainsInvalidEscape"] = 2048] = "ContainsInvalidEscape";
4043
+ TokenFlags2[TokenFlags2["HexEscape"] = 4096] = "HexEscape";
4044
+ TokenFlags2[TokenFlags2["ContainsLeadingZero"] = 8192] = "ContainsLeadingZero";
4045
+ TokenFlags2[TokenFlags2["ContainsInvalidSeparator"] = 16384] = "ContainsInvalidSeparator";
4043
4046
  TokenFlags2[TokenFlags2["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier";
4044
- TokenFlags2[TokenFlags2["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags";
4045
- TokenFlags2[TokenFlags2["TemplateLiteralLikeFlags"] = 2048 /* ContainsInvalidEscape */] = "TemplateLiteralLikeFlags";
4047
+ TokenFlags2[TokenFlags2["WithSpecifier"] = 448] = "WithSpecifier";
4048
+ TokenFlags2[TokenFlags2["StringLiteralFlags"] = 7176] = "StringLiteralFlags";
4049
+ TokenFlags2[TokenFlags2["NumericLiteralFlags"] = 25584] = "NumericLiteralFlags";
4050
+ TokenFlags2[TokenFlags2["TemplateLiteralLikeFlags"] = 7176] = "TemplateLiteralLikeFlags";
4051
+ TokenFlags2[TokenFlags2["IsInvalid"] = 26656] = "IsInvalid";
4046
4052
  return TokenFlags2;
4047
4053
  })(TokenFlags || {});
4048
4054
  FlowFlags = /* @__PURE__ */ ((FlowFlags2) => {
@@ -7056,7 +7062,6 @@ ${lanes.join("\n")}
7056
7062
  _0_modifier_cannot_appear_on_an_index_signature: diag(1071, 1 /* Error */, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."),
7057
7063
  A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, 1 /* Error */, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."),
7058
7064
  Invalid_reference_directive_syntax: diag(1084, 1 /* Error */, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
7059
- Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, 1 /* Error */, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."),
7060
7065
  _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, 1 /* Error */, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."),
7061
7066
  _0_modifier_cannot_appear_on_a_parameter: diag(1090, 1 /* Error */, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."),
7062
7067
  Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, 1 /* Error */, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."),
@@ -7087,7 +7092,7 @@ ${lanes.join("\n")}
7087
7092
  An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, 1 /* Error */, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."),
7088
7093
  An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, 1 /* Error */, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."),
7089
7094
  An_export_assignment_cannot_have_modifiers: diag(1120, 1 /* Error */, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
7090
- Octal_literals_are_not_allowed_in_strict_mode: diag(1121, 1 /* Error */, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."),
7095
+ Octal_literals_are_not_allowed_Use_the_syntax_0: diag(1121, 1 /* Error */, "Octal_literals_are_not_allowed_Use_the_syntax_0_1121", "Octal literals are not allowed. Use the syntax '{0}'."),
7091
7096
  Variable_declaration_list_cannot_be_empty: diag(1123, 1 /* Error */, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
7092
7097
  Digit_expected: diag(1124, 1 /* Error */, "Digit_expected_1124", "Digit expected."),
7093
7098
  Hexadecimal_digit_expected: diag(1125, 1 /* Error */, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
@@ -7398,6 +7403,9 @@ ${lanes.join("\n")}
7398
7403
  _0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled: diag(1484, 1 /* Error */, "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled_1484", "'{0}' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled."),
7399
7404
  _0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled: diag(1485, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimMo_1485", "'{0}' resolves to a type-only declaration and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled."),
7400
7405
  Decorator_used_before_export_here: diag(1486, 1 /* Error */, "Decorator_used_before_export_here_1486", "Decorator used before 'export' here."),
7406
+ Octal_escape_sequences_are_not_allowed_Use_the_syntax_0: diag(1487, 1 /* Error */, "Octal_escape_sequences_are_not_allowed_Use_the_syntax_0_1487", "Octal escape sequences are not allowed. Use the syntax '{0}'."),
7407
+ Escape_sequence_0_is_not_allowed: diag(1488, 1 /* Error */, "Escape_sequence_0_is_not_allowed_1488", "Escape sequence '{0}' is not allowed."),
7408
+ Decimals_with_leading_zeros_are_not_allowed: diag(1489, 1 /* Error */, "Decimals_with_leading_zeros_are_not_allowed_1489", "Decimals with leading zeros are not allowed."),
7401
7409
  The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
7402
7410
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
7403
7411
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -8738,8 +8746,6 @@ ${lanes.join("\n")}
8738
8746
  Parameter_modifiers_can_only_be_used_in_TypeScript_files: diag(8012, 1 /* Error */, "Parameter_modifiers_can_only_be_used_in_TypeScript_files_8012", "Parameter modifiers can only be used in TypeScript files."),
8739
8747
  Non_null_assertions_can_only_be_used_in_TypeScript_files: diag(8013, 1 /* Error */, "Non_null_assertions_can_only_be_used_in_TypeScript_files_8013", "Non-null assertions can only be used in TypeScript files."),
8740
8748
  Type_assertion_expressions_can_only_be_used_in_TypeScript_files: diag(8016, 1 /* Error */, "Type_assertion_expressions_can_only_be_used_in_TypeScript_files_8016", "Type assertion expressions can only be used in TypeScript files."),
8741
- Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: diag(8017, 1 /* Error */, "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", "Octal literal types must use ES2015 syntax. Use the syntax '{0}'."),
8742
- Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, 1 /* Error */, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."),
8743
8749
  Report_errors_in_js_files: diag(8019, 3 /* Message */, "Report_errors_in_js_files_8019", "Report errors in .js files."),
8744
8750
  JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, 1 /* Error */, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."),
8745
8751
  JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, 1 /* Error */, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."),
@@ -9584,7 +9590,7 @@ ${lanes.join("\n")}
9584
9590
  isReservedWord: () => token >= 82 /* FirstReservedWord */ && token <= 117 /* LastReservedWord */,
9585
9591
  isUnterminated: () => (tokenFlags & 4 /* Unterminated */) !== 0,
9586
9592
  getCommentDirectives: () => commentDirectives,
9587
- getNumericLiteralFlags: () => tokenFlags & 1008 /* NumericLiteralFlags */,
9593
+ getNumericLiteralFlags: () => tokenFlags & 25584 /* NumericLiteralFlags */,
9588
9594
  getTokenFlags: () => tokenFlags,
9589
9595
  reScanGreaterToken,
9590
9596
  reScanAsteriskEqualsToken,
@@ -9625,11 +9631,11 @@ ${lanes.join("\n")}
9625
9631
  });
9626
9632
  }
9627
9633
  return scanner2;
9628
- function error(message, errPos = pos, length3) {
9634
+ function error(message, errPos = pos, length3, arg0) {
9629
9635
  if (onError) {
9630
9636
  const oldPos = pos;
9631
9637
  pos = errPos;
9632
- onError(message, length3 || 0);
9638
+ onError(message, length3 || 0, arg0);
9633
9639
  pos = oldPos;
9634
9640
  }
9635
9641
  }
@@ -9646,10 +9652,13 @@ ${lanes.join("\n")}
9646
9652
  allowSeparator = false;
9647
9653
  isPreviousTokenSeparator = true;
9648
9654
  result += text.substring(start2, pos);
9649
- } else if (isPreviousTokenSeparator) {
9650
- error(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
9651
9655
  } else {
9652
- error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
9656
+ tokenFlags |= 16384 /* ContainsInvalidSeparator */;
9657
+ if (isPreviousTokenSeparator) {
9658
+ error(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
9659
+ } else {
9660
+ error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
9661
+ }
9653
9662
  }
9654
9663
  pos++;
9655
9664
  start2 = pos;
@@ -9664,13 +9673,39 @@ ${lanes.join("\n")}
9664
9673
  break;
9665
9674
  }
9666
9675
  if (text.charCodeAt(pos - 1) === 95 /* _ */) {
9676
+ tokenFlags |= 16384 /* ContainsInvalidSeparator */;
9667
9677
  error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
9668
9678
  }
9669
9679
  return result + text.substring(start2, pos);
9670
9680
  }
9671
9681
  function scanNumber() {
9672
- const start2 = pos;
9673
- const mainFragment = scanNumberFragment();
9682
+ let start2 = pos;
9683
+ let mainFragment;
9684
+ if (text.charCodeAt(pos) === 48 /* _0 */) {
9685
+ pos++;
9686
+ if (text.charCodeAt(pos) === 95 /* _ */) {
9687
+ tokenFlags |= 512 /* ContainsSeparator */ | 16384 /* ContainsInvalidSeparator */;
9688
+ error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
9689
+ pos--;
9690
+ mainFragment = scanNumberFragment();
9691
+ } else if (!scanDigits()) {
9692
+ tokenFlags |= 8192 /* ContainsLeadingZero */;
9693
+ mainFragment = "" + +tokenValue;
9694
+ } else if (!tokenValue) {
9695
+ mainFragment = "0";
9696
+ } else {
9697
+ tokenValue = "" + parseInt(tokenValue, 8);
9698
+ tokenFlags |= 32 /* Octal */;
9699
+ const withMinus = token === 40 /* MinusToken */;
9700
+ const literal = (withMinus ? "-" : "") + "0o" + (+tokenValue).toString(8);
9701
+ if (withMinus)
9702
+ start2--;
9703
+ error(Diagnostics.Octal_literals_are_not_allowed_Use_the_syntax_0, start2, pos - start2, literal);
9704
+ return { type: 8 /* NumericLiteral */, value: tokenValue };
9705
+ }
9706
+ } else {
9707
+ mainFragment = scanNumberFragment();
9708
+ }
9674
9709
  let decimalFragment;
9675
9710
  let scientificFragment;
9676
9711
  if (text.charCodeAt(pos) === 46 /* dot */) {
@@ -9704,6 +9739,10 @@ ${lanes.join("\n")}
9704
9739
  } else {
9705
9740
  result = text.substring(start2, end2);
9706
9741
  }
9742
+ if (tokenFlags & 8192 /* ContainsLeadingZero */) {
9743
+ error(Diagnostics.Decimals_with_leading_zeros_are_not_allowed, start2, end2 - start2);
9744
+ return { type: 8 /* NumericLiteral */, value: "" + +result };
9745
+ }
9707
9746
  if (decimalFragment !== void 0 || tokenFlags & 16 /* Scientific */) {
9708
9747
  checkForIdentifierStartAfterNumericLiteral(start2, decimalFragment === void 0 && !!(tokenFlags & 16 /* Scientific */));
9709
9748
  return {
@@ -9735,12 +9774,17 @@ ${lanes.join("\n")}
9735
9774
  pos = identifierStart;
9736
9775
  }
9737
9776
  }
9738
- function scanOctalDigits() {
9777
+ function scanDigits() {
9739
9778
  const start2 = pos;
9740
- while (isOctalDigit(text.charCodeAt(pos))) {
9779
+ let isOctal = true;
9780
+ while (isDigit(text.charCodeAt(pos))) {
9781
+ if (!isOctalDigit(text.charCodeAt(pos))) {
9782
+ isOctal = false;
9783
+ }
9741
9784
  pos++;
9742
9785
  }
9743
- return +text.substring(start2, pos);
9786
+ tokenValue = text.substring(start2, pos);
9787
+ return isOctal;
9744
9788
  }
9745
9789
  function scanExactNumberOfHexDigits(count, canHaveSeparators) {
9746
9790
  const valueString = scanHexDigits(
@@ -9818,7 +9862,10 @@ ${lanes.join("\n")}
9818
9862
  }
9819
9863
  if (ch === 92 /* backslash */ && !jsxAttributeString) {
9820
9864
  result += text.substring(start2, pos);
9821
- result += scanEscapeSequence();
9865
+ result += scanEscapeSequence(
9866
+ /*shouldEmitInvalidEscapeError*/
9867
+ true
9868
+ );
9822
9869
  start2 = pos;
9823
9870
  continue;
9824
9871
  }
@@ -9832,7 +9879,7 @@ ${lanes.join("\n")}
9832
9879
  }
9833
9880
  return result;
9834
9881
  }
9835
- function scanTemplateAndSetTokenValue(isTaggedTemplate) {
9882
+ function scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError) {
9836
9883
  const startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */;
9837
9884
  pos++;
9838
9885
  let start2 = pos;
@@ -9861,7 +9908,7 @@ ${lanes.join("\n")}
9861
9908
  }
9862
9909
  if (currChar === 92 /* backslash */) {
9863
9910
  contents += text.substring(start2, pos);
9864
- contents += scanEscapeSequence(isTaggedTemplate);
9911
+ contents += scanEscapeSequence(shouldEmitInvalidEscapeError);
9865
9912
  start2 = pos;
9866
9913
  continue;
9867
9914
  }
@@ -9881,7 +9928,7 @@ ${lanes.join("\n")}
9881
9928
  tokenValue = contents;
9882
9929
  return resultingToken;
9883
9930
  }
9884
- function scanEscapeSequence(isTaggedTemplate) {
9931
+ function scanEscapeSequence(shouldEmitInvalidEscapeError) {
9885
9932
  const start2 = pos;
9886
9933
  pos++;
9887
9934
  if (pos >= end) {
@@ -9892,12 +9939,37 @@ ${lanes.join("\n")}
9892
9939
  pos++;
9893
9940
  switch (ch) {
9894
9941
  case 48 /* _0 */:
9895
- if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
9942
+ if (pos >= end || !isDigit(text.charCodeAt(pos))) {
9943
+ return "\0";
9944
+ }
9945
+ case 49 /* _1 */:
9946
+ case 50 /* _2 */:
9947
+ case 51 /* _3 */:
9948
+ if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
9896
9949
  pos++;
9897
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
9898
- return text.substring(start2, pos);
9899
9950
  }
9900
- return "\0";
9951
+ case 52 /* _4 */:
9952
+ case 53 /* _5 */:
9953
+ case 54 /* _6 */:
9954
+ case 55 /* _7 */:
9955
+ if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
9956
+ pos++;
9957
+ }
9958
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
9959
+ if (shouldEmitInvalidEscapeError) {
9960
+ const code = parseInt(text.substring(start2 + 1, pos), 8);
9961
+ error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + padLeft(code.toString(16), 2, "0"));
9962
+ return String.fromCharCode(code);
9963
+ }
9964
+ return text.substring(start2, pos);
9965
+ case 56 /* _8 */:
9966
+ case 57 /* _9 */:
9967
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
9968
+ if (shouldEmitInvalidEscapeError) {
9969
+ error(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
9970
+ return String.fromCharCode(ch);
9971
+ }
9972
+ return text.substring(start2, pos);
9901
9973
  case 98 /* b */:
9902
9974
  return "\b";
9903
9975
  case 116 /* t */:
@@ -9915,59 +9987,69 @@ ${lanes.join("\n")}
9915
9987
  case 34 /* doubleQuote */:
9916
9988
  return '"';
9917
9989
  case 117 /* u */:
9918
- if (isTaggedTemplate) {
9919
- for (let escapePos = pos; escapePos < pos + 4; escapePos++) {
9920
- if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) {
9921
- pos = escapePos;
9922
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
9923
- return text.substring(start2, pos);
9924
- }
9925
- }
9926
- }
9927
9990
  if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
9928
9991
  pos++;
9929
- if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
9992
+ const escapedValueString = scanMinimumNumberOfHexDigits(
9993
+ 1,
9994
+ /*canHaveSeparators*/
9995
+ false
9996
+ );
9997
+ const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
9998
+ if (escapedValue < 0) {
9930
9999
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
10000
+ if (shouldEmitInvalidEscapeError) {
10001
+ error(Diagnostics.Hexadecimal_digit_expected);
10002
+ }
9931
10003
  return text.substring(start2, pos);
9932
10004
  }
9933
- if (isTaggedTemplate) {
9934
- const savePos = pos;
9935
- const escapedValueString = scanMinimumNumberOfHexDigits(
9936
- 1,
9937
- /*canHaveSeparators*/
9938
- false
9939
- );
9940
- const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
9941
- if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) {
9942
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
9943
- return text.substring(start2, pos);
9944
- } else {
9945
- pos = savePos;
10005
+ if (!isCodePoint(escapedValue)) {
10006
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
10007
+ if (shouldEmitInvalidEscapeError) {
10008
+ error(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
9946
10009
  }
10010
+ return text.substring(start2, pos);
9947
10011
  }
10012
+ if (pos >= end) {
10013
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
10014
+ if (shouldEmitInvalidEscapeError) {
10015
+ error(Diagnostics.Unexpected_end_of_text);
10016
+ }
10017
+ return text.substring(start2, pos);
10018
+ }
10019
+ if (text.charCodeAt(pos) !== 125 /* closeBrace */) {
10020
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
10021
+ if (shouldEmitInvalidEscapeError) {
10022
+ error(Diagnostics.Unterminated_Unicode_escape_sequence);
10023
+ }
10024
+ return text.substring(start2, pos);
10025
+ }
10026
+ pos++;
9948
10027
  tokenFlags |= 8 /* ExtendedUnicodeEscape */;
9949
- return scanExtendedUnicodeEscape();
10028
+ return utf16EncodeAsString(escapedValue);
9950
10029
  }
9951
- tokenFlags |= 1024 /* UnicodeEscape */;
9952
- return scanHexadecimalEscape(
9953
- /*numDigits*/
9954
- 4
9955
- );
9956
- case 120 /* x */:
9957
- if (isTaggedTemplate) {
9958
- if (!isHexDigit(text.charCodeAt(pos))) {
10030
+ for (; pos < start2 + 6; pos++) {
10031
+ if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
9959
10032
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
10033
+ if (shouldEmitInvalidEscapeError) {
10034
+ error(Diagnostics.Hexadecimal_digit_expected);
10035
+ }
9960
10036
  return text.substring(start2, pos);
9961
- } else if (!isHexDigit(text.charCodeAt(pos + 1))) {
9962
- pos++;
10037
+ }
10038
+ }
10039
+ tokenFlags |= 1024 /* UnicodeEscape */;
10040
+ return String.fromCharCode(parseInt(text.substring(start2 + 2, pos), 16));
10041
+ case 120 /* x */:
10042
+ for (; pos < start2 + 4; pos++) {
10043
+ if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
9963
10044
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
10045
+ if (shouldEmitInvalidEscapeError) {
10046
+ error(Diagnostics.Hexadecimal_digit_expected);
10047
+ }
9964
10048
  return text.substring(start2, pos);
9965
10049
  }
9966
10050
  }
9967
- return scanHexadecimalEscape(
9968
- /*numDigits*/
9969
- 2
9970
- );
10051
+ tokenFlags |= 4096 /* HexEscape */;
10052
+ return String.fromCharCode(parseInt(text.substring(start2 + 2, pos), 16));
9971
10053
  case 13 /* carriageReturn */:
9972
10054
  if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
9973
10055
  pos++;
@@ -9980,19 +10062,6 @@ ${lanes.join("\n")}
9980
10062
  return String.fromCharCode(ch);
9981
10063
  }
9982
10064
  }
9983
- function scanHexadecimalEscape(numDigits) {
9984
- const escapedValue = scanExactNumberOfHexDigits(
9985
- numDigits,
9986
- /*canHaveSeparators*/
9987
- false
9988
- );
9989
- if (escapedValue >= 0) {
9990
- return String.fromCharCode(escapedValue);
9991
- } else {
9992
- error(Diagnostics.Hexadecimal_digit_expected);
9993
- return "";
9994
- }
9995
- }
9996
10065
  function scanExtendedUnicodeEscape() {
9997
10066
  const escapedValueString = scanMinimumNumberOfHexDigits(
9998
10067
  1,
@@ -10221,7 +10290,7 @@ ${lanes.join("\n")}
10221
10290
  return token = 10 /* StringLiteral */;
10222
10291
  case 96 /* backtick */:
10223
10292
  return token = scanTemplateAndSetTokenValue(
10224
- /*isTaggedTemplate*/
10293
+ /*shouldEmitInvalidEscapeError*/
10225
10294
  false
10226
10295
  );
10227
10296
  case 37 /* percent */:
@@ -10396,11 +10465,6 @@ ${lanes.join("\n")}
10396
10465
  tokenFlags |= 256 /* OctalSpecifier */;
10397
10466
  return token = checkBigIntSuffix();
10398
10467
  }
10399
- if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
10400
- tokenValue = "" + scanOctalDigits();
10401
- tokenFlags |= 32 /* Octal */;
10402
- return token = 8 /* NumericLiteral */;
10403
- }
10404
10468
  case 49 /* _1 */:
10405
10469
  case 50 /* _2 */:
10406
10470
  case 51 /* _3 */:
@@ -10717,14 +10781,13 @@ ${lanes.join("\n")}
10717
10781
  return void 0;
10718
10782
  }
10719
10783
  function reScanTemplateToken(isTaggedTemplate) {
10720
- Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
10721
10784
  pos = tokenStart;
10722
- return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
10785
+ return token = scanTemplateAndSetTokenValue(!isTaggedTemplate);
10723
10786
  }
10724
10787
  function reScanTemplateHeadOrNoSubstitutionTemplate() {
10725
10788
  pos = tokenStart;
10726
10789
  return token = scanTemplateAndSetTokenValue(
10727
- /*isTaggedTemplate*/
10790
+ /*shouldEmitInvalidEscapeError*/
10728
10791
  true
10729
10792
  );
10730
10793
  }
@@ -13607,8 +13670,13 @@ ${lanes.join("\n")}
13607
13670
  if (nodeIsSynthesized(node) || !node.parent || flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) {
13608
13671
  return false;
13609
13672
  }
13610
- if (isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) {
13611
- return !!(flags & 8 /* AllowNumericSeparator */);
13673
+ if (isNumericLiteral(node)) {
13674
+ if (node.numericLiteralFlags & 26656 /* IsInvalid */) {
13675
+ return false;
13676
+ }
13677
+ if (node.numericLiteralFlags & 512 /* ContainsSeparator */) {
13678
+ return !!(flags & 8 /* AllowNumericSeparator */);
13679
+ }
13612
13680
  }
13613
13681
  return !isBigIntLiteral(node);
13614
13682
  }
@@ -21844,7 +21912,7 @@ ${lanes.join("\n")}
21844
21912
  return node.head !== head || node.templateSpans !== templateSpans ? update(createTemplateExpression(head, templateSpans), node) : node;
21845
21913
  }
21846
21914
  function checkTemplateLiteralLikeNode(kind, text, rawText, templateFlags = 0 /* None */) {
21847
- Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags.");
21915
+ Debug.assert(!(templateFlags & ~7176 /* TemplateLiteralLikeFlags */), "Unsupported template flags.");
21848
21916
  let cooked = void 0;
21849
21917
  if (rawText !== void 0 && rawText !== text) {
21850
21918
  cooked = getCookedText(kind, rawText);
@@ -21873,7 +21941,7 @@ ${lanes.join("\n")}
21873
21941
  const node = createBaseToken(kind);
21874
21942
  node.text = text;
21875
21943
  node.rawText = rawText;
21876
- node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */;
21944
+ node.templateFlags = templateFlags & 7176 /* TemplateLiteralLikeFlags */;
21877
21945
  node.transformFlags = getTransformFlagsOfTemplateLiteralLike(node.templateFlags);
21878
21946
  return node;
21879
21947
  }
@@ -21881,7 +21949,7 @@ ${lanes.join("\n")}
21881
21949
  const node = createBaseDeclaration(kind);
21882
21950
  node.text = text;
21883
21951
  node.rawText = rawText;
21884
- node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */;
21952
+ node.templateFlags = templateFlags & 7176 /* TemplateLiteralLikeFlags */;
21885
21953
  node.transformFlags = getTransformFlagsOfTemplateLiteralLike(node.templateFlags);
21886
21954
  return node;
21887
21955
  }
@@ -28997,8 +29065,8 @@ ${lanes.join("\n")}
28997
29065
  function parseErrorAtRange(range, message, ...args) {
28998
29066
  parseErrorAt(range.pos, range.end, message, ...args);
28999
29067
  }
29000
- function scanError(message, length2) {
29001
- parseErrorAtPosition(scanner2.getTokenEnd(), length2, message);
29068
+ function scanError(message, length2, arg0) {
29069
+ parseErrorAtPosition(scanner2.getTokenEnd(), length2, message, arg0);
29002
29070
  }
29003
29071
  function getNodePos() {
29004
29072
  return scanner2.getTokenFullStart();
@@ -29037,9 +29105,6 @@ ${lanes.join("\n")}
29037
29105
  function reScanTemplateToken(isTaggedTemplate) {
29038
29106
  return currentToken = scanner2.reScanTemplateToken(isTaggedTemplate);
29039
29107
  }
29040
- function reScanTemplateHeadOrNoSubstitutionTemplate() {
29041
- return currentToken = scanner2.reScanTemplateHeadOrNoSubstitutionTemplate();
29042
- }
29043
29108
  function reScanLessThanToken() {
29044
29109
  return currentToken = scanner2.reScanLessThanToken();
29045
29110
  }
@@ -30111,8 +30176,11 @@ ${lanes.join("\n")}
30111
30176
  return parseLiteralLikeNode(token());
30112
30177
  }
30113
30178
  function parseTemplateHead(isTaggedTemplate) {
30114
- if (isTaggedTemplate) {
30115
- reScanTemplateHeadOrNoSubstitutionTemplate();
30179
+ if (!isTaggedTemplate && scanner2.getTokenFlags() & 26656 /* IsInvalid */) {
30180
+ reScanTemplateToken(
30181
+ /*isTaggedTemplate*/
30182
+ false
30183
+ );
30116
30184
  }
30117
30185
  const fragment = parseLiteralLikeNode(token());
30118
30186
  Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind");
@@ -30130,8 +30198,7 @@ ${lanes.join("\n")}
30130
30198
  }
30131
30199
  function parseLiteralLikeNode(kind) {
30132
30200
  const pos = getNodePos();
30133
- const node = isTemplateLiteralKind(kind) ? factory2.createTemplateLiteralLikeNode(kind, scanner2.getTokenValue(), getTemplateLiteralRawText(kind), scanner2.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : (
30134
- // Octal literals are not allowed in strict mode or ES5
30201
+ const node = isTemplateLiteralKind(kind) ? factory2.createTemplateLiteralLikeNode(kind, scanner2.getTokenValue(), getTemplateLiteralRawText(kind), scanner2.getTokenFlags() & 7176 /* TemplateLiteralLikeFlags */) : (
30135
30202
  // Note that theoretically the following condition would hold true literals like 009,
30136
30203
  // which is not octal. But because of how the scanner separates the tokens, we would
30137
30204
  // never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
@@ -32187,7 +32254,10 @@ ${lanes.join("\n")}
32187
32254
  const tagExpression = factory2.createTaggedTemplateExpression(
32188
32255
  tag,
32189
32256
  typeArguments,
32190
- token() === 14 /* NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(
32257
+ token() === 14 /* NoSubstitutionTemplateLiteral */ ? (reScanTemplateToken(
32258
+ /*isTaggedTemplate*/
32259
+ true
32260
+ ), parseLiteralNode()) : parseTemplateExpression(
32191
32261
  /*isTaggedTemplate*/
32192
32262
  true
32193
32263
  )
@@ -32275,10 +32345,16 @@ ${lanes.join("\n")}
32275
32345
  }
32276
32346
  function parsePrimaryExpression() {
32277
32347
  switch (token()) {
32348
+ case 14 /* NoSubstitutionTemplateLiteral */:
32349
+ if (scanner2.getTokenFlags() & 26656 /* IsInvalid */) {
32350
+ reScanTemplateToken(
32351
+ /*isTaggedTemplate*/
32352
+ false
32353
+ );
32354
+ }
32278
32355
  case 8 /* NumericLiteral */:
32279
32356
  case 9 /* BigIntLiteral */:
32280
32357
  case 10 /* StringLiteral */:
32281
- case 14 /* NoSubstitutionTemplateLiteral */:
32282
32358
  return parseLiteralNode();
32283
32359
  case 109 /* ThisKeyword */:
32284
32360
  case 107 /* SuperKeyword */:
@@ -42893,11 +42969,6 @@ ${lanes.join("\n")}
42893
42969
  }
42894
42970
  }
42895
42971
  }
42896
- function checkStrictModeNumericLiteral(node) {
42897
- if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
42898
- file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
42899
- }
42900
- }
42901
42972
  function checkStrictModePostfixUnaryExpression(node) {
42902
42973
  if (inStrictMode) {
42903
42974
  checkStrictModeEvalOrArguments(node, node.operand);
@@ -43089,8 +43160,6 @@ ${lanes.join("\n")}
43089
43160
  return checkStrictModeCatchClause(node);
43090
43161
  case 218 /* DeleteExpression */:
43091
43162
  return checkStrictModeDeleteExpression(node);
43092
- case 8 /* NumericLiteral */:
43093
- return checkStrictModeNumericLiteral(node);
43094
43163
  case 223 /* PostfixUnaryExpression */:
43095
43164
  return checkStrictModePostfixUnaryExpression(node);
43096
43165
  case 222 /* PrefixUnaryExpression */:
@@ -85113,25 +85182,6 @@ ${lanes.join("\n")}
85113
85182
  return false;
85114
85183
  }
85115
85184
  function checkGrammarNumericLiteral(node) {
85116
- if (node.numericLiteralFlags & 32 /* Octal */) {
85117
- let diagnosticMessage;
85118
- if (languageVersion >= 1 /* ES5 */) {
85119
- diagnosticMessage = Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
85120
- } else if (isChildOfNodeWithKind(node, 199 /* LiteralType */)) {
85121
- diagnosticMessage = Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
85122
- } else if (isChildOfNodeWithKind(node, 303 /* EnumMember */)) {
85123
- diagnosticMessage = Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
85124
- }
85125
- if (diagnosticMessage) {
85126
- const withMinus = isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */;
85127
- const literal = (withMinus ? "-" : "") + "0o" + node.text;
85128
- return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
85129
- }
85130
- }
85131
- checkNumericLiteralValueSize(node);
85132
- return false;
85133
- }
85134
- function checkNumericLiteralValueSize(node) {
85135
85185
  const isFractional = getTextOfNode(node).indexOf(".") !== -1;
85136
85186
  const isScientific = node.numericLiteralFlags & 16 /* Scientific */;
85137
85187
  if (isFractional || isScientific) {
@@ -88399,7 +88449,7 @@ ${lanes.join("\n")}
88399
88449
  );
88400
88450
  }
88401
88451
  function createTemplateCooked(factory2, template) {
88402
- return template.templateFlags ? factory2.createVoidZero() : factory2.createStringLiteral(template.text);
88452
+ return template.templateFlags & 26656 /* IsInvalid */ ? factory2.createVoidZero() : factory2.createStringLiteral(template.text);
88403
88453
  }
88404
88454
  function getRawLiteral(factory2, node, currentSourceFile) {
88405
88455
  let text = node.rawText;
@@ -111717,7 +111767,7 @@ ${lanes.join("\n")}
111717
111767
  /*jsxAttributeEscape*/
111718
111768
  false
111719
111769
  );
111720
- return !expression.numericLiteralFlags && !stringContains(text, tokenToString(24 /* DotToken */));
111770
+ return !(expression.numericLiteralFlags & 448 /* WithSpecifier */) && !stringContains(text, tokenToString(24 /* DotToken */)) && !stringContains(text, String.fromCharCode(69 /* E */)) && !stringContains(text, String.fromCharCode(101 /* e */));
111721
111771
  } else if (isAccessExpression(expression)) {
111722
111772
  const constantValue = getConstantValue(expression);
111723
111773
  return typeof constantValue === "number" && isFinite(constantValue) && Math.floor(constantValue) === constantValue;
@@ -119280,7 +119330,6 @@ ${lanes.join("\n")}
119280
119330
  Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
119281
119331
  Diagnostics.Invalid_use_of_0_in_strict_mode.code,
119282
119332
  Diagnostics.A_label_is_not_allowed_here.code,
119283
- Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
119284
119333
  Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
119285
119334
  // grammar errors
119286
119335
  Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement.code,