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/tsserver.js CHANGED
@@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(server_exports);
2286
2286
 
2287
2287
  // src/compiler/corePublic.ts
2288
2288
  var versionMajorMinor = "5.1";
2289
- var version = `${versionMajorMinor}.0-dev.20230324`;
2289
+ var version = `${versionMajorMinor}.0-dev.20230325`;
2290
2290
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2291
2291
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2292
2292
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6234,9 +6234,15 @@ var TokenFlags = /* @__PURE__ */ ((TokenFlags2) => {
6234
6234
  TokenFlags2[TokenFlags2["ContainsSeparator"] = 512] = "ContainsSeparator";
6235
6235
  TokenFlags2[TokenFlags2["UnicodeEscape"] = 1024] = "UnicodeEscape";
6236
6236
  TokenFlags2[TokenFlags2["ContainsInvalidEscape"] = 2048] = "ContainsInvalidEscape";
6237
+ TokenFlags2[TokenFlags2["HexEscape"] = 4096] = "HexEscape";
6238
+ TokenFlags2[TokenFlags2["ContainsLeadingZero"] = 8192] = "ContainsLeadingZero";
6239
+ TokenFlags2[TokenFlags2["ContainsInvalidSeparator"] = 16384] = "ContainsInvalidSeparator";
6237
6240
  TokenFlags2[TokenFlags2["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier";
6238
- TokenFlags2[TokenFlags2["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags";
6239
- TokenFlags2[TokenFlags2["TemplateLiteralLikeFlags"] = 2048 /* ContainsInvalidEscape */] = "TemplateLiteralLikeFlags";
6241
+ TokenFlags2[TokenFlags2["WithSpecifier"] = 448] = "WithSpecifier";
6242
+ TokenFlags2[TokenFlags2["StringLiteralFlags"] = 7176] = "StringLiteralFlags";
6243
+ TokenFlags2[TokenFlags2["NumericLiteralFlags"] = 25584] = "NumericLiteralFlags";
6244
+ TokenFlags2[TokenFlags2["TemplateLiteralLikeFlags"] = 7176] = "TemplateLiteralLikeFlags";
6245
+ TokenFlags2[TokenFlags2["IsInvalid"] = 26656] = "IsInvalid";
6240
6246
  return TokenFlags2;
6241
6247
  })(TokenFlags || {});
6242
6248
  var FlowFlags = /* @__PURE__ */ ((FlowFlags2) => {
@@ -9233,7 +9239,6 @@ var Diagnostics = {
9233
9239
  _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."),
9234
9240
  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."),
9235
9241
  Invalid_reference_directive_syntax: diag(1084, 1 /* Error */, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
9236
- 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}'."),
9237
9242
  _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."),
9238
9243
  _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."),
9239
9244
  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."),
@@ -9264,7 +9269,7 @@ var Diagnostics = {
9264
9269
  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."),
9265
9270
  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."),
9266
9271
  An_export_assignment_cannot_have_modifiers: diag(1120, 1 /* Error */, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
9267
- 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."),
9272
+ 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}'."),
9268
9273
  Variable_declaration_list_cannot_be_empty: diag(1123, 1 /* Error */, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
9269
9274
  Digit_expected: diag(1124, 1 /* Error */, "Digit_expected_1124", "Digit expected."),
9270
9275
  Hexadecimal_digit_expected: diag(1125, 1 /* Error */, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
@@ -9575,6 +9580,9 @@ var Diagnostics = {
9575
9580
  _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."),
9576
9581
  _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."),
9577
9582
  Decorator_used_before_export_here: diag(1486, 1 /* Error */, "Decorator_used_before_export_here_1486", "Decorator used before 'export' here."),
9583
+ 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}'."),
9584
+ Escape_sequence_0_is_not_allowed: diag(1488, 1 /* Error */, "Escape_sequence_0_is_not_allowed_1488", "Escape sequence '{0}' is not allowed."),
9585
+ 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."),
9578
9586
  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."),
9579
9587
  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."),
9580
9588
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -10915,8 +10923,6 @@ var Diagnostics = {
10915
10923
  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."),
10916
10924
  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."),
10917
10925
  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."),
10918
- 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}'."),
10919
- 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}'."),
10920
10926
  Report_errors_in_js_files: diag(8019, 3 /* Message */, "Report_errors_in_js_files_8019", "Report errors in .js files."),
10921
10927
  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."),
10922
10928
  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."),
@@ -11919,7 +11925,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
11919
11925
  isReservedWord: () => token >= 82 /* FirstReservedWord */ && token <= 117 /* LastReservedWord */,
11920
11926
  isUnterminated: () => (tokenFlags & 4 /* Unterminated */) !== 0,
11921
11927
  getCommentDirectives: () => commentDirectives,
11922
- getNumericLiteralFlags: () => tokenFlags & 1008 /* NumericLiteralFlags */,
11928
+ getNumericLiteralFlags: () => tokenFlags & 25584 /* NumericLiteralFlags */,
11923
11929
  getTokenFlags: () => tokenFlags,
11924
11930
  reScanGreaterToken,
11925
11931
  reScanAsteriskEqualsToken,
@@ -11960,11 +11966,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
11960
11966
  });
11961
11967
  }
11962
11968
  return scanner2;
11963
- function error(message, errPos = pos, length3) {
11969
+ function error(message, errPos = pos, length3, arg0) {
11964
11970
  if (onError) {
11965
11971
  const oldPos = pos;
11966
11972
  pos = errPos;
11967
- onError(message, length3 || 0);
11973
+ onError(message, length3 || 0, arg0);
11968
11974
  pos = oldPos;
11969
11975
  }
11970
11976
  }
@@ -11981,10 +11987,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
11981
11987
  allowSeparator = false;
11982
11988
  isPreviousTokenSeparator = true;
11983
11989
  result += text.substring(start3, pos);
11984
- } else if (isPreviousTokenSeparator) {
11985
- error(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
11986
11990
  } else {
11987
- error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
11991
+ tokenFlags |= 16384 /* ContainsInvalidSeparator */;
11992
+ if (isPreviousTokenSeparator) {
11993
+ error(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
11994
+ } else {
11995
+ error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
11996
+ }
11988
11997
  }
11989
11998
  pos++;
11990
11999
  start3 = pos;
@@ -11999,13 +12008,39 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
11999
12008
  break;
12000
12009
  }
12001
12010
  if (text.charCodeAt(pos - 1) === 95 /* _ */) {
12011
+ tokenFlags |= 16384 /* ContainsInvalidSeparator */;
12002
12012
  error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
12003
12013
  }
12004
12014
  return result + text.substring(start3, pos);
12005
12015
  }
12006
12016
  function scanNumber() {
12007
- const start3 = pos;
12008
- const mainFragment = scanNumberFragment();
12017
+ let start3 = pos;
12018
+ let mainFragment;
12019
+ if (text.charCodeAt(pos) === 48 /* _0 */) {
12020
+ pos++;
12021
+ if (text.charCodeAt(pos) === 95 /* _ */) {
12022
+ tokenFlags |= 512 /* ContainsSeparator */ | 16384 /* ContainsInvalidSeparator */;
12023
+ error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
12024
+ pos--;
12025
+ mainFragment = scanNumberFragment();
12026
+ } else if (!scanDigits()) {
12027
+ tokenFlags |= 8192 /* ContainsLeadingZero */;
12028
+ mainFragment = "" + +tokenValue;
12029
+ } else if (!tokenValue) {
12030
+ mainFragment = "0";
12031
+ } else {
12032
+ tokenValue = "" + parseInt(tokenValue, 8);
12033
+ tokenFlags |= 32 /* Octal */;
12034
+ const withMinus = token === 40 /* MinusToken */;
12035
+ const literal = (withMinus ? "-" : "") + "0o" + (+tokenValue).toString(8);
12036
+ if (withMinus)
12037
+ start3--;
12038
+ error(Diagnostics.Octal_literals_are_not_allowed_Use_the_syntax_0, start3, pos - start3, literal);
12039
+ return { type: 8 /* NumericLiteral */, value: tokenValue };
12040
+ }
12041
+ } else {
12042
+ mainFragment = scanNumberFragment();
12043
+ }
12009
12044
  let decimalFragment;
12010
12045
  let scientificFragment;
12011
12046
  if (text.charCodeAt(pos) === 46 /* dot */) {
@@ -12039,6 +12074,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12039
12074
  } else {
12040
12075
  result = text.substring(start3, end2);
12041
12076
  }
12077
+ if (tokenFlags & 8192 /* ContainsLeadingZero */) {
12078
+ error(Diagnostics.Decimals_with_leading_zeros_are_not_allowed, start3, end2 - start3);
12079
+ return { type: 8 /* NumericLiteral */, value: "" + +result };
12080
+ }
12042
12081
  if (decimalFragment !== void 0 || tokenFlags & 16 /* Scientific */) {
12043
12082
  checkForIdentifierStartAfterNumericLiteral(start3, decimalFragment === void 0 && !!(tokenFlags & 16 /* Scientific */));
12044
12083
  return {
@@ -12070,12 +12109,17 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12070
12109
  pos = identifierStart;
12071
12110
  }
12072
12111
  }
12073
- function scanOctalDigits() {
12112
+ function scanDigits() {
12074
12113
  const start3 = pos;
12075
- while (isOctalDigit(text.charCodeAt(pos))) {
12114
+ let isOctal = true;
12115
+ while (isDigit(text.charCodeAt(pos))) {
12116
+ if (!isOctalDigit(text.charCodeAt(pos))) {
12117
+ isOctal = false;
12118
+ }
12076
12119
  pos++;
12077
12120
  }
12078
- return +text.substring(start3, pos);
12121
+ tokenValue = text.substring(start3, pos);
12122
+ return isOctal;
12079
12123
  }
12080
12124
  function scanExactNumberOfHexDigits(count, canHaveSeparators) {
12081
12125
  const valueString = scanHexDigits(
@@ -12153,7 +12197,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12153
12197
  }
12154
12198
  if (ch === 92 /* backslash */ && !jsxAttributeString) {
12155
12199
  result += text.substring(start3, pos);
12156
- result += scanEscapeSequence();
12200
+ result += scanEscapeSequence(
12201
+ /*shouldEmitInvalidEscapeError*/
12202
+ true
12203
+ );
12157
12204
  start3 = pos;
12158
12205
  continue;
12159
12206
  }
@@ -12167,7 +12214,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12167
12214
  }
12168
12215
  return result;
12169
12216
  }
12170
- function scanTemplateAndSetTokenValue(isTaggedTemplate) {
12217
+ function scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError) {
12171
12218
  const startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */;
12172
12219
  pos++;
12173
12220
  let start3 = pos;
@@ -12196,7 +12243,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12196
12243
  }
12197
12244
  if (currChar === 92 /* backslash */) {
12198
12245
  contents += text.substring(start3, pos);
12199
- contents += scanEscapeSequence(isTaggedTemplate);
12246
+ contents += scanEscapeSequence(shouldEmitInvalidEscapeError);
12200
12247
  start3 = pos;
12201
12248
  continue;
12202
12249
  }
@@ -12216,7 +12263,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12216
12263
  tokenValue = contents;
12217
12264
  return resultingToken;
12218
12265
  }
12219
- function scanEscapeSequence(isTaggedTemplate) {
12266
+ function scanEscapeSequence(shouldEmitInvalidEscapeError) {
12220
12267
  const start3 = pos;
12221
12268
  pos++;
12222
12269
  if (pos >= end) {
@@ -12227,12 +12274,37 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12227
12274
  pos++;
12228
12275
  switch (ch) {
12229
12276
  case 48 /* _0 */:
12230
- if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
12277
+ if (pos >= end || !isDigit(text.charCodeAt(pos))) {
12278
+ return "\0";
12279
+ }
12280
+ case 49 /* _1 */:
12281
+ case 50 /* _2 */:
12282
+ case 51 /* _3 */:
12283
+ if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
12231
12284
  pos++;
12232
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
12233
- return text.substring(start3, pos);
12234
12285
  }
12235
- return "\0";
12286
+ case 52 /* _4 */:
12287
+ case 53 /* _5 */:
12288
+ case 54 /* _6 */:
12289
+ case 55 /* _7 */:
12290
+ if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
12291
+ pos++;
12292
+ }
12293
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
12294
+ if (shouldEmitInvalidEscapeError) {
12295
+ const code = parseInt(text.substring(start3 + 1, pos), 8);
12296
+ error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start3, pos - start3, "\\x" + padLeft(code.toString(16), 2, "0"));
12297
+ return String.fromCharCode(code);
12298
+ }
12299
+ return text.substring(start3, pos);
12300
+ case 56 /* _8 */:
12301
+ case 57 /* _9 */:
12302
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
12303
+ if (shouldEmitInvalidEscapeError) {
12304
+ error(Diagnostics.Escape_sequence_0_is_not_allowed, start3, pos - start3, text.substring(start3, pos));
12305
+ return String.fromCharCode(ch);
12306
+ }
12307
+ return text.substring(start3, pos);
12236
12308
  case 98 /* b */:
12237
12309
  return "\b";
12238
12310
  case 116 /* t */:
@@ -12250,59 +12322,69 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12250
12322
  case 34 /* doubleQuote */:
12251
12323
  return '"';
12252
12324
  case 117 /* u */:
12253
- if (isTaggedTemplate) {
12254
- for (let escapePos = pos; escapePos < pos + 4; escapePos++) {
12255
- if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) {
12256
- pos = escapePos;
12257
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
12258
- return text.substring(start3, pos);
12259
- }
12260
- }
12261
- }
12262
12325
  if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
12263
12326
  pos++;
12264
- if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
12327
+ const escapedValueString = scanMinimumNumberOfHexDigits(
12328
+ 1,
12329
+ /*canHaveSeparators*/
12330
+ false
12331
+ );
12332
+ const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
12333
+ if (escapedValue < 0) {
12265
12334
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12335
+ if (shouldEmitInvalidEscapeError) {
12336
+ error(Diagnostics.Hexadecimal_digit_expected);
12337
+ }
12266
12338
  return text.substring(start3, pos);
12267
12339
  }
12268
- if (isTaggedTemplate) {
12269
- const savePos = pos;
12270
- const escapedValueString = scanMinimumNumberOfHexDigits(
12271
- 1,
12272
- /*canHaveSeparators*/
12273
- false
12274
- );
12275
- const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
12276
- if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) {
12277
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
12278
- return text.substring(start3, pos);
12279
- } else {
12280
- pos = savePos;
12340
+ if (!isCodePoint(escapedValue)) {
12341
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
12342
+ if (shouldEmitInvalidEscapeError) {
12343
+ error(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
12281
12344
  }
12345
+ return text.substring(start3, pos);
12282
12346
  }
12347
+ if (pos >= end) {
12348
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
12349
+ if (shouldEmitInvalidEscapeError) {
12350
+ error(Diagnostics.Unexpected_end_of_text);
12351
+ }
12352
+ return text.substring(start3, pos);
12353
+ }
12354
+ if (text.charCodeAt(pos) !== 125 /* closeBrace */) {
12355
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
12356
+ if (shouldEmitInvalidEscapeError) {
12357
+ error(Diagnostics.Unterminated_Unicode_escape_sequence);
12358
+ }
12359
+ return text.substring(start3, pos);
12360
+ }
12361
+ pos++;
12283
12362
  tokenFlags |= 8 /* ExtendedUnicodeEscape */;
12284
- return scanExtendedUnicodeEscape();
12363
+ return utf16EncodeAsString(escapedValue);
12285
12364
  }
12286
- tokenFlags |= 1024 /* UnicodeEscape */;
12287
- return scanHexadecimalEscape(
12288
- /*numDigits*/
12289
- 4
12290
- );
12291
- case 120 /* x */:
12292
- if (isTaggedTemplate) {
12293
- if (!isHexDigit(text.charCodeAt(pos))) {
12365
+ for (; pos < start3 + 6; pos++) {
12366
+ if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
12294
12367
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12368
+ if (shouldEmitInvalidEscapeError) {
12369
+ error(Diagnostics.Hexadecimal_digit_expected);
12370
+ }
12295
12371
  return text.substring(start3, pos);
12296
- } else if (!isHexDigit(text.charCodeAt(pos + 1))) {
12297
- pos++;
12372
+ }
12373
+ }
12374
+ tokenFlags |= 1024 /* UnicodeEscape */;
12375
+ return String.fromCharCode(parseInt(text.substring(start3 + 2, pos), 16));
12376
+ case 120 /* x */:
12377
+ for (; pos < start3 + 4; pos++) {
12378
+ if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
12298
12379
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12380
+ if (shouldEmitInvalidEscapeError) {
12381
+ error(Diagnostics.Hexadecimal_digit_expected);
12382
+ }
12299
12383
  return text.substring(start3, pos);
12300
12384
  }
12301
12385
  }
12302
- return scanHexadecimalEscape(
12303
- /*numDigits*/
12304
- 2
12305
- );
12386
+ tokenFlags |= 4096 /* HexEscape */;
12387
+ return String.fromCharCode(parseInt(text.substring(start3 + 2, pos), 16));
12306
12388
  case 13 /* carriageReturn */:
12307
12389
  if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
12308
12390
  pos++;
@@ -12315,19 +12397,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12315
12397
  return String.fromCharCode(ch);
12316
12398
  }
12317
12399
  }
12318
- function scanHexadecimalEscape(numDigits) {
12319
- const escapedValue = scanExactNumberOfHexDigits(
12320
- numDigits,
12321
- /*canHaveSeparators*/
12322
- false
12323
- );
12324
- if (escapedValue >= 0) {
12325
- return String.fromCharCode(escapedValue);
12326
- } else {
12327
- error(Diagnostics.Hexadecimal_digit_expected);
12328
- return "";
12329
- }
12330
- }
12331
12400
  function scanExtendedUnicodeEscape() {
12332
12401
  const escapedValueString = scanMinimumNumberOfHexDigits(
12333
12402
  1,
@@ -12556,7 +12625,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12556
12625
  return token = 10 /* StringLiteral */;
12557
12626
  case 96 /* backtick */:
12558
12627
  return token = scanTemplateAndSetTokenValue(
12559
- /*isTaggedTemplate*/
12628
+ /*shouldEmitInvalidEscapeError*/
12560
12629
  false
12561
12630
  );
12562
12631
  case 37 /* percent */:
@@ -12731,11 +12800,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12731
12800
  tokenFlags |= 256 /* OctalSpecifier */;
12732
12801
  return token = checkBigIntSuffix();
12733
12802
  }
12734
- if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
12735
- tokenValue = "" + scanOctalDigits();
12736
- tokenFlags |= 32 /* Octal */;
12737
- return token = 8 /* NumericLiteral */;
12738
- }
12739
12803
  case 49 /* _1 */:
12740
12804
  case 50 /* _2 */:
12741
12805
  case 51 /* _3 */:
@@ -13052,14 +13116,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13052
13116
  return void 0;
13053
13117
  }
13054
13118
  function reScanTemplateToken(isTaggedTemplate) {
13055
- Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
13056
13119
  pos = tokenStart;
13057
- return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
13120
+ return token = scanTemplateAndSetTokenValue(!isTaggedTemplate);
13058
13121
  }
13059
13122
  function reScanTemplateHeadOrNoSubstitutionTemplate() {
13060
13123
  pos = tokenStart;
13061
13124
  return token = scanTemplateAndSetTokenValue(
13062
- /*isTaggedTemplate*/
13125
+ /*shouldEmitInvalidEscapeError*/
13063
13126
  true
13064
13127
  );
13065
13128
  }
@@ -15781,8 +15844,13 @@ function canUseOriginalText(node, flags) {
15781
15844
  if (nodeIsSynthesized(node) || !node.parent || flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) {
15782
15845
  return false;
15783
15846
  }
15784
- if (isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) {
15785
- return !!(flags & 8 /* AllowNumericSeparator */);
15847
+ if (isNumericLiteral(node)) {
15848
+ if (node.numericLiteralFlags & 26656 /* IsInvalid */) {
15849
+ return false;
15850
+ }
15851
+ if (node.numericLiteralFlags & 512 /* ContainsSeparator */) {
15852
+ return !!(flags & 8 /* AllowNumericSeparator */);
15853
+ }
15786
15854
  }
15787
15855
  return !isBigIntLiteral(node);
15788
15856
  }
@@ -23989,7 +24057,7 @@ function createNodeFactory(flags, baseFactory2) {
23989
24057
  return node.head !== head || node.templateSpans !== templateSpans ? update(createTemplateExpression(head, templateSpans), node) : node;
23990
24058
  }
23991
24059
  function checkTemplateLiteralLikeNode(kind, text, rawText, templateFlags = 0 /* None */) {
23992
- Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags.");
24060
+ Debug.assert(!(templateFlags & ~7176 /* TemplateLiteralLikeFlags */), "Unsupported template flags.");
23993
24061
  let cooked = void 0;
23994
24062
  if (rawText !== void 0 && rawText !== text) {
23995
24063
  cooked = getCookedText(kind, rawText);
@@ -24018,7 +24086,7 @@ function createNodeFactory(flags, baseFactory2) {
24018
24086
  const node = createBaseToken(kind);
24019
24087
  node.text = text;
24020
24088
  node.rawText = rawText;
24021
- node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */;
24089
+ node.templateFlags = templateFlags & 7176 /* TemplateLiteralLikeFlags */;
24022
24090
  node.transformFlags = getTransformFlagsOfTemplateLiteralLike(node.templateFlags);
24023
24091
  return node;
24024
24092
  }
@@ -24026,7 +24094,7 @@ function createNodeFactory(flags, baseFactory2) {
24026
24094
  const node = createBaseDeclaration(kind);
24027
24095
  node.text = text;
24028
24096
  node.rawText = rawText;
24029
- node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */;
24097
+ node.templateFlags = templateFlags & 7176 /* TemplateLiteralLikeFlags */;
24030
24098
  node.transformFlags = getTransformFlagsOfTemplateLiteralLike(node.templateFlags);
24031
24099
  return node;
24032
24100
  }
@@ -30887,8 +30955,8 @@ var Parser;
30887
30955
  function parseErrorAtRange(range, message, ...args) {
30888
30956
  parseErrorAt(range.pos, range.end, message, ...args);
30889
30957
  }
30890
- function scanError(message, length2) {
30891
- parseErrorAtPosition(scanner2.getTokenEnd(), length2, message);
30958
+ function scanError(message, length2, arg0) {
30959
+ parseErrorAtPosition(scanner2.getTokenEnd(), length2, message, arg0);
30892
30960
  }
30893
30961
  function getNodePos() {
30894
30962
  return scanner2.getTokenFullStart();
@@ -30927,9 +30995,6 @@ var Parser;
30927
30995
  function reScanTemplateToken(isTaggedTemplate) {
30928
30996
  return currentToken = scanner2.reScanTemplateToken(isTaggedTemplate);
30929
30997
  }
30930
- function reScanTemplateHeadOrNoSubstitutionTemplate() {
30931
- return currentToken = scanner2.reScanTemplateHeadOrNoSubstitutionTemplate();
30932
- }
30933
30998
  function reScanLessThanToken() {
30934
30999
  return currentToken = scanner2.reScanLessThanToken();
30935
31000
  }
@@ -32001,8 +32066,11 @@ var Parser;
32001
32066
  return parseLiteralLikeNode(token());
32002
32067
  }
32003
32068
  function parseTemplateHead(isTaggedTemplate) {
32004
- if (isTaggedTemplate) {
32005
- reScanTemplateHeadOrNoSubstitutionTemplate();
32069
+ if (!isTaggedTemplate && scanner2.getTokenFlags() & 26656 /* IsInvalid */) {
32070
+ reScanTemplateToken(
32071
+ /*isTaggedTemplate*/
32072
+ false
32073
+ );
32006
32074
  }
32007
32075
  const fragment = parseLiteralLikeNode(token());
32008
32076
  Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind");
@@ -32020,8 +32088,7 @@ var Parser;
32020
32088
  }
32021
32089
  function parseLiteralLikeNode(kind) {
32022
32090
  const pos = getNodePos();
32023
- const node = isTemplateLiteralKind(kind) ? factory2.createTemplateLiteralLikeNode(kind, scanner2.getTokenValue(), getTemplateLiteralRawText(kind), scanner2.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : (
32024
- // Octal literals are not allowed in strict mode or ES5
32091
+ const node = isTemplateLiteralKind(kind) ? factory2.createTemplateLiteralLikeNode(kind, scanner2.getTokenValue(), getTemplateLiteralRawText(kind), scanner2.getTokenFlags() & 7176 /* TemplateLiteralLikeFlags */) : (
32025
32092
  // Note that theoretically the following condition would hold true literals like 009,
32026
32093
  // which is not octal. But because of how the scanner separates the tokens, we would
32027
32094
  // never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
@@ -34077,7 +34144,10 @@ var Parser;
34077
34144
  const tagExpression = factory2.createTaggedTemplateExpression(
34078
34145
  tag,
34079
34146
  typeArguments,
34080
- token() === 14 /* NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(
34147
+ token() === 14 /* NoSubstitutionTemplateLiteral */ ? (reScanTemplateToken(
34148
+ /*isTaggedTemplate*/
34149
+ true
34150
+ ), parseLiteralNode()) : parseTemplateExpression(
34081
34151
  /*isTaggedTemplate*/
34082
34152
  true
34083
34153
  )
@@ -34165,10 +34235,16 @@ var Parser;
34165
34235
  }
34166
34236
  function parsePrimaryExpression() {
34167
34237
  switch (token()) {
34238
+ case 14 /* NoSubstitutionTemplateLiteral */:
34239
+ if (scanner2.getTokenFlags() & 26656 /* IsInvalid */) {
34240
+ reScanTemplateToken(
34241
+ /*isTaggedTemplate*/
34242
+ false
34243
+ );
34244
+ }
34168
34245
  case 8 /* NumericLiteral */:
34169
34246
  case 9 /* BigIntLiteral */:
34170
34247
  case 10 /* StringLiteral */:
34171
- case 14 /* NoSubstitutionTemplateLiteral */:
34172
34248
  return parseLiteralNode();
34173
34249
  case 109 /* ThisKeyword */:
34174
34250
  case 107 /* SuperKeyword */:
@@ -44993,11 +45069,6 @@ function createBinder() {
44993
45069
  }
44994
45070
  }
44995
45071
  }
44996
- function checkStrictModeNumericLiteral(node) {
44997
- if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
44998
- file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
44999
- }
45000
- }
45001
45072
  function checkStrictModePostfixUnaryExpression(node) {
45002
45073
  if (inStrictMode) {
45003
45074
  checkStrictModeEvalOrArguments(node, node.operand);
@@ -45189,8 +45260,6 @@ function createBinder() {
45189
45260
  return checkStrictModeCatchClause(node);
45190
45261
  case 218 /* DeleteExpression */:
45191
45262
  return checkStrictModeDeleteExpression(node);
45192
- case 8 /* NumericLiteral */:
45193
- return checkStrictModeNumericLiteral(node);
45194
45263
  case 223 /* PostfixUnaryExpression */:
45195
45264
  return checkStrictModePostfixUnaryExpression(node);
45196
45265
  case 222 /* PrefixUnaryExpression */:
@@ -87305,25 +87374,6 @@ function createTypeChecker(host) {
87305
87374
  return false;
87306
87375
  }
87307
87376
  function checkGrammarNumericLiteral(node) {
87308
- if (node.numericLiteralFlags & 32 /* Octal */) {
87309
- let diagnosticMessage;
87310
- if (languageVersion >= 1 /* ES5 */) {
87311
- diagnosticMessage = Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
87312
- } else if (isChildOfNodeWithKind(node, 199 /* LiteralType */)) {
87313
- diagnosticMessage = Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
87314
- } else if (isChildOfNodeWithKind(node, 303 /* EnumMember */)) {
87315
- diagnosticMessage = Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
87316
- }
87317
- if (diagnosticMessage) {
87318
- const withMinus = isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */;
87319
- const literal = (withMinus ? "-" : "") + "0o" + node.text;
87320
- return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
87321
- }
87322
- }
87323
- checkNumericLiteralValueSize(node);
87324
- return false;
87325
- }
87326
- function checkNumericLiteralValueSize(node) {
87327
87377
  const isFractional = getTextOfNode(node).indexOf(".") !== -1;
87328
87378
  const isScientific = node.numericLiteralFlags & 16 /* Scientific */;
87329
87379
  if (isFractional || isScientific) {
@@ -90435,7 +90485,7 @@ function processTaggedTemplateExpression(context, node, visitor, currentSourceFi
90435
90485
  );
90436
90486
  }
90437
90487
  function createTemplateCooked(factory2, template) {
90438
- return template.templateFlags ? factory2.createVoidZero() : factory2.createStringLiteral(template.text);
90488
+ return template.templateFlags & 26656 /* IsInvalid */ ? factory2.createVoidZero() : factory2.createStringLiteral(template.text);
90439
90489
  }
90440
90490
  function getRawLiteral(factory2, node, currentSourceFile) {
90441
90491
  let text = node.rawText;
@@ -113644,7 +113694,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
113644
113694
  /*jsxAttributeEscape*/
113645
113695
  false
113646
113696
  );
113647
- return !expression.numericLiteralFlags && !stringContains(text, tokenToString(24 /* DotToken */));
113697
+ return !(expression.numericLiteralFlags & 448 /* WithSpecifier */) && !stringContains(text, tokenToString(24 /* DotToken */)) && !stringContains(text, String.fromCharCode(69 /* E */)) && !stringContains(text, String.fromCharCode(101 /* e */));
113648
113698
  } else if (isAccessExpression(expression)) {
113649
113699
  const constantValue = getConstantValue(expression);
113650
113700
  return typeof constantValue === "number" && isFinite(constantValue) && Math.floor(constantValue) === constantValue;
@@ -117946,7 +117996,6 @@ var plainJSErrors = /* @__PURE__ */ new Set([
117946
117996
  Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
117947
117997
  Diagnostics.Invalid_use_of_0_in_strict_mode.code,
117948
117998
  Diagnostics.A_label_is_not_allowed_here.code,
117949
- Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
117950
117999
  Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
117951
118000
  // grammar errors
117952
118001
  Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement.code,
@@ -8360,7 +8360,7 @@ declare namespace ts {
8360
8360
  function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean;
8361
8361
  function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean;
8362
8362
  function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, textInitial?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
8363
- type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
8363
+ type ErrorCallback = (message: DiagnosticMessage, length: number, arg0?: any) => void;
8364
8364
  interface Scanner {
8365
8365
  /** @deprecated use {@link getTokenFullStart} */
8366
8366
  getStartPos(): number;
@@ -8384,6 +8384,7 @@ declare namespace ts {
8384
8384
  reScanSlashToken(): SyntaxKind;
8385
8385
  reScanAsteriskEqualsToken(): SyntaxKind;
8386
8386
  reScanTemplateToken(isTaggedTemplate: boolean): SyntaxKind;
8387
+ /** @deprecated use {@link reScanTemplateToken}(false) */
8387
8388
  reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind;
8388
8389
  scanJsxIdentifier(): SyntaxKind;
8389
8390
  scanJsxAttributeValue(): SyntaxKind;