From c356203d2bd5bf9edf0012d179128a02f74b7bf3 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 11 Jun 2025 23:36:24 -0700 Subject: [PATCH] Remove ES5 specific identifier handling --- src/compiler/checker.ts | 20 +- src/compiler/expressionToTypeNode.ts | 3 +- src/compiler/parser.ts | 2 +- src/compiler/program.ts | 2 +- src/compiler/scanner.ts | 99 +-- src/compiler/transformers/classFields.ts | 2 +- src/compiler/transformers/declarations.ts | 3 +- src/compiler/transformers/esDecorators.ts | 3 +- src/compiler/utilities.ts | 10 +- .../codefixes/convertFunctionToEs6Class.ts | 14 +- src/services/codefixes/convertToEsModule.ts | 2 +- .../codefixes/fixAddMissingConstraint.ts | 4 +- src/services/codefixes/fixAddMissingMember.ts | 16 +- src/services/codefixes/fixAddMissingParam.ts | 6 +- .../fixMissingTypeAnnotationOnExports.ts | 8 +- src/services/codefixes/fixSpelling.ts | 12 +- src/services/codefixes/helpers.ts | 34 +- src/services/codefixes/importFixes.ts | 3 +- src/services/codefixes/inferFromUsage.ts | 7 +- src/services/completions.ts | 19 +- src/services/exportInfoMap.ts | 4 +- src/services/findAllReferences.ts | 5 +- src/services/inlayHints.ts | 4 +- src/services/patternMatcher.ts | 5 +- src/services/refactors/convertImport.ts | 3 +- src/services/refactors/extractSymbol.ts | 4 +- src/services/refactors/helpers.ts | 2 +- src/services/refactors/moveToFile.ts | 9 +- src/services/stringCompletions.ts | 2 +- src/services/utilities.ts | 14 +- .../unittests/services/extract/helpers.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 4 +- ...odeEscapesInNames02(target=es5).errors.txt | 128 +--- .../unicodeEscapesInNames02(target=es5).js | 53 +- ...unicodeEscapesInNames02(target=es5).js.map | 4 +- ...EscapesInNames02(target=es5).sourcemap.txt | 697 +++++------------- ...nicodeEscapesInNames02(target=es5).symbols | 39 +- .../unicodeEscapesInNames02(target=es5).types | 131 ++-- 38 files changed, 412 insertions(+), 967 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 76002f24ace..b9b13abc2d4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6485,7 +6485,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return parentName; } const memberName = symbolName(type.symbol); - if (isIdentifierText(memberName, ScriptTarget.ES5)) { + if (isIdentifierText(memberName)) { return appendReferenceToType( parentName as TypeReferenceNode | ImportTypeNode, factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined), @@ -8509,7 +8509,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isSingleOrDoubleQuote(firstChar) && some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - if (index === 0 || canUsePropertyAccess(symbolName, languageVersion)) { + if (index === 0 || canUsePropertyAccess(symbolName)) { const identifier = setEmitFlags(factory.createIdentifier(symbolName), EmitFlags.NoAsciiEscaping); if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes)); identifier.symbol = symbol; @@ -8569,7 +8569,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return fromNameType; } const rawName = unescapeLeadingUnderscores(symbol.escapedName); - return createPropertyNameNodeForIdentifierOrLiteral(rawName, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod); + return createPropertyNameNodeForIdentifierOrLiteral(rawName, singleQuote, stringNamed, isMethod); } // See getNameForSymbolFromNameType for a stringy equivalent @@ -8578,13 +8578,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (nameType) { if (nameType.flags & TypeFlags.StringOrNumberLiteral) { const name = "" + (nameType as StringLiteralType | NumberLiteralType).value; - if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) { + if (!isIdentifierText(name) && (stringNamed || !isNumericLiteralName(name))) { return factory.createStringLiteral(name, !!singleQuote); } if (isNumericLiteralName(name) && startsWith(name, "-")) { return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-name))); } - return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod); + return createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote, stringNamed, isMethod); } if (nameType.flags & TypeFlags.UniqueESSymbol) { return factory.createComputedPropertyName(symbolToExpression((nameType as UniqueESSymbolType).symbol, context, SymbolFlags.Value)); @@ -9511,7 +9511,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } exports = arrayFrom(membersSet); } - return filter(exports, m => isNamespaceMember(m) && isIdentifierText(m.escapedName as string, ScriptTarget.ESNext)); + return filter(exports, m => isNamespaceMember(m) && isIdentifierText(m.escapedName as string)); } function isTypeOnlyNamespace(symbol: Symbol) { @@ -10169,7 +10169,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { !some(getPropertiesOfType(typeToSerialize), p => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), p => some(p.declarations, d => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), p => { - if (!isIdentifierText(symbolName(p), languageVersion)) { + if (!isIdentifierText(symbolName(p))) { return false; } if (!(p.flags & SymbolFlags.Accessor)) { @@ -10497,7 +10497,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else if (localName === InternalSymbolName.ExportEquals) { localName = "_exports"; } - localName = isIdentifierText(localName, languageVersion) && !isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-z0-9]/gi, "_"); + localName = isIdentifierText(localName) && !isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-z0-9]/gi, "_"); return localName; } @@ -10588,7 +10588,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (nameType) { if (nameType.flags & TypeFlags.StringOrNumberLiteral) { const name = "" + (nameType as StringLiteralType | NumberLiteralType).value; - if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) { + if (!isIdentifierText(name) && !isNumericLiteralName(name)) { return `"${escapeString(name, CharacterCodes.doubleQuote)}"`; } if (isNumericLiteralName(name) && startsWith(name, "-")) { @@ -21839,7 +21839,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { path = `${str}`; } // Otherwise write a dotted name if possible - else if (isIdentifierText(str, getEmitScriptTarget(compilerOptions))) { + else if (isIdentifierText(str)) { path = `${path}.${str}`; } // Failing that, check if the name is already a computed name diff --git a/src/compiler/expressionToTypeNode.ts b/src/compiler/expressionToTypeNode.ts index bb3db3bd0cc..577a9545684 100644 --- a/src/compiler/expressionToTypeNode.ts +++ b/src/compiler/expressionToTypeNode.ts @@ -25,7 +25,6 @@ import { getEffectiveSetAccessorTypeAnnotationNode, getEffectiveTypeAnnotationNode, getEmitFlags, - getEmitScriptTarget, getFunctionFlags, getJSDocType, getJSDocTypeAssertionType, @@ -502,7 +501,7 @@ export function createSyntacticTypeNodeBuilder( } literal = literalNode; } - if (literal.kind === SyntaxKind.StringLiteral && isIdentifierText(literal.text, getEmitScriptTarget(options))) { + if (literal.kind === SyntaxKind.StringLiteral && isIdentifierText(literal.text)) { return factory.createIdentifier(literal.text); } if (literal.kind === SyntaxKind.NumericLiteral && !literal.text.startsWith("-")) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8c69cccba12..3294eb08a00 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2371,7 +2371,7 @@ namespace Parser { // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. const expressionText = isIdentifierNode(node) ? idText(node) : undefined; - if (!expressionText || !isIdentifierText(expressionText, languageVersion)) { + if (!expressionText || !isIdentifierText(expressionText)) { parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); return; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 48d8d07f164..e0238d10943 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4364,7 +4364,7 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro createOptionValueDiagnostic("jsxFactory", Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory); } } - else if (options.reactNamespace && !isIdentifierText(options.reactNamespace, languageVersion)) { + else if (options.reactNamespace && !isIdentifierText(options.reactNamespace)) { createOptionValueDiagnostic("reactNamespace", Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 50e827c17bd..2fb0527c598 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -304,33 +304,6 @@ const regExpFlagToFirstAvailableLanguageVersion = new Map, or - . - - Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: - http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt -*/ -// dprint-ignore -const unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500 ]; -// dprint-ignore -const unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500 ]; - /** * Generated by scripts/regenerate-unicode-identifier-parts.mjs on node v22.1.0 with unicode 15.1 * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords @@ -385,16 +358,12 @@ function lookupInUnicodeMap(code: number, map: readonly number[]): boolean { } /** @internal */ -export function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget | undefined): boolean { - return languageVersion! >= ScriptTarget.ES2015 ? - lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - lookupInUnicodeMap(code, unicodeES5IdentifierStart); +export function isUnicodeIdentifierStart(code: number): boolean { + return lookupInUnicodeMap(code, unicodeESNextIdentifierStart); } -function isUnicodeIdentifierPart(code: number, languageVersion: ScriptTarget | undefined) { - return languageVersion! >= ScriptTarget.ES2015 ? - lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - lookupInUnicodeMap(code, unicodeES5IdentifierPart); +function isUnicodeIdentifierPart(code: number) { + return lookupInUnicodeMap(code, unicodeESNextIdentifierPart); } function makeReverseMap(source: Map): T[] { @@ -969,27 +938,27 @@ export function getShebang(text: string): string | undefined { } } -export function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean { +export function isIdentifierStart(ch: number): boolean { return isASCIILetter(ch) || ch === CharacterCodes.$ || ch === CharacterCodes._ || - ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch, languageVersion); + ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch); } -export function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean { +export function isIdentifierPart(ch: number, identifierVariant?: LanguageVariant): boolean { return isWordCharacter(ch) || ch === CharacterCodes.$ || // "-" and ":" are valid in JSX Identifiers (identifierVariant === LanguageVariant.JSX ? (ch === CharacterCodes.minus || ch === CharacterCodes.colon) : false) || - ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); + ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch); } /** @internal */ -export function isIdentifierText(name: string, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean { +export function isIdentifierText(name: string, identifierVariant?: LanguageVariant): boolean { let ch = codePointAt(name, 0); - if (!isIdentifierStart(ch, languageVersion)) { + if (!isIdentifierStart(ch)) { return false; } for (let i = charSize(ch); i < name.length; i += charSize(ch)) { - if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) { + if (!isIdentifierPart(ch = codePointAt(name, i), identifierVariant)) { return false; } } @@ -1323,7 +1292,7 @@ export function createScanner( } function checkForIdentifierStartAfterNumericLiteral(numericStart: number, isScientific?: boolean) { - if (!isIdentifierStart(codePointUnchecked(pos), languageVersion)) { + if (!isIdentifierStart(codePointUnchecked(pos))) { return; } @@ -1696,7 +1665,7 @@ export function createScanner( flags & EscapeSequenceScanningFlags.AnyUnicodeMode || flags & EscapeSequenceScanningFlags.RegularExpression && !(flags & EscapeSequenceScanningFlags.AnnexB) - && isIdentifierPart(ch, languageVersion) + && isIdentifierPart(ch) ) { error(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2); } @@ -1782,18 +1751,18 @@ export function createScanner( let start = pos; while (pos < end) { let ch = codePointUnchecked(pos); - if (isIdentifierPart(ch, languageVersion)) { + if (isIdentifierPart(ch)) { pos += charSize(ch); } else if (ch === CharacterCodes.backslash) { ch = peekExtendedUnicodeEscape(); - if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + if (ch >= 0 && isIdentifierPart(ch)) { result += scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true); start = pos; continue; } ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { + if (!(ch >= 0 && isIdentifierPart(ch))) { break; } tokenFlags |= TokenFlags.UnicodeEscape; @@ -2304,13 +2273,13 @@ export function createScanner( return token = SyntaxKind.AtToken; case CharacterCodes.backslash: const extendedCookedChar = peekExtendedUnicodeEscape(); - if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar)) { tokenValue = scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true) + scanIdentifierParts(); return token = getIdentifierToken(); } const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { pos += 6; tokenFlags |= TokenFlags.UnicodeEscape; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); @@ -2331,13 +2300,13 @@ export function createScanner( if (charAfterHash === CharacterCodes.backslash) { pos++; const extendedCookedChar = peekExtendedUnicodeEscape(); - if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar)) { tokenValue = "#" + scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true) + scanIdentifierParts(); return token = SyntaxKind.PrivateIdentifier; } const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { pos += 6; tokenFlags |= TokenFlags.UnicodeEscape; tokenValue = "#" + String.fromCharCode(cookedChar) + scanIdentifierParts(); @@ -2346,14 +2315,14 @@ export function createScanner( pos--; } - if (isIdentifierStart(charAfterHash, languageVersion)) { + if (isIdentifierStart(charAfterHash)) { pos++; // We're relying on scanIdentifier's behavior and adjusting the token kind after the fact. // Notably absent from this block is the fact that calling a function named "scanIdentifier", // but identifiers don't include '#', and that function doesn't deal with it at all. // This works because 'scanIdentifier' tries to reuse source characters and builds up substrings; // however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us. - scanIdentifier(charAfterHash, languageVersion); + scanIdentifier(charAfterHash); } else { tokenValue = "#"; @@ -2365,7 +2334,7 @@ export function createScanner( pos = end; return token = SyntaxKind.NonTextFileMarkerTrivia; default: - const identifierKind = scanIdentifier(ch, languageVersion); + const identifierKind = scanIdentifier(ch); if (identifierKind) { return token = identifierKind; } @@ -2413,7 +2382,7 @@ export function createScanner( pos = tokenStart = fullStartPos; tokenFlags = 0; const ch = codePointUnchecked(pos); - const identifierKind = scanIdentifier(ch, ScriptTarget.ESNext); + const identifierKind = scanIdentifier(ch); if (identifierKind) { return token = identifierKind; } @@ -2421,11 +2390,11 @@ export function createScanner( return token; // Still `SyntaxKind.Unknown` } - function scanIdentifier(startCharacter: number, languageVersion: ScriptTarget) { + function scanIdentifier(startCharacter: number) { let ch = startCharacter; - if (isIdentifierStart(ch, languageVersion)) { + if (isIdentifierStart(ch)) { pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos), languageVersion)) pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos))) pos += charSize(ch); tokenValue = text.substring(tokenStart, pos); if (ch === CharacterCodes.backslash) { tokenValue += scanIdentifierParts(); @@ -2575,7 +2544,7 @@ export function createScanner( let regExpFlags = RegularExpressionFlags.None; while (true) { const ch = codePointChecked(pos); - if (ch === CharacterCodes.EOF || !isIdentifierPart(ch, languageVersion)) { + if (ch === CharacterCodes.EOF || !isIdentifierPart(ch)) { break; } const size = charSize(ch); @@ -2861,7 +2830,7 @@ export function createScanner( function scanPatternModifiers(currFlags: RegularExpressionFlags): RegularExpressionFlags { while (true) { const ch = codePointChecked(pos); - if (ch === CharacterCodes.EOF || !isIdentifierPart(ch, languageVersion)) { + if (ch === CharacterCodes.EOF || !isIdentifierPart(ch)) { break; } const size = charSize(ch); @@ -2996,7 +2965,7 @@ export function createScanner( function scanGroupName(isReference: boolean) { Debug.assertEqual(charCodeUnchecked(pos - 1), CharacterCodes.lessThan); tokenStart = pos; - scanIdentifier(codePointChecked(pos), languageVersion); + scanIdentifier(codePointChecked(pos)); if (pos === tokenStart) { error(Diagnostics.Expected_a_capturing_group_name); } @@ -3896,13 +3865,13 @@ export function createScanner( case CharacterCodes.backslash: pos--; const extendedCookedChar = peekExtendedUnicodeEscape(); - if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar)) { tokenValue = scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true) + scanIdentifierParts(); return token = getIdentifierToken(); } const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { pos += 6; tokenFlags |= TokenFlags.UnicodeEscape; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); @@ -3912,9 +3881,9 @@ export function createScanner( return token = SyntaxKind.Unknown; } - if (isIdentifierStart(ch, languageVersion)) { + if (isIdentifierStart(ch)) { let char = ch; - while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus) pos += charSize(char); + while (pos < end && isIdentifierPart(char = codePointUnchecked(pos)) || char === CharacterCodes.minus) pos += charSize(char); tokenValue = text.substring(tokenStart, pos); if (char === CharacterCodes.backslash) { tokenValue += scanIdentifierParts(); diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 7d8bc6f8eab..91b033e16ac 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -1819,7 +1819,7 @@ export function transformClassFields(context: TransformationContext): (x: Source } // If the class name was assigned from a string literal that is a valid identifier, create an // identifier from it. - else if (isIdentifierText(node.emitNode.assignedName.text, languageVersion)) { + else if (isIdentifierText(node.emitNode.assignedName.text)) { const prefixName = factory.createIdentifier(node.emitNode.assignedName.text); getPrivateIdentifierEnvironment().data.className = prefixName; } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 7c41bcccc3e..b18464fe052 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -179,7 +179,6 @@ import { PropertySignature, pushIfUnique, removeAllComments, - ScriptTarget, SetAccessorDeclaration, setCommentRange, setEmitFlags, @@ -1466,7 +1465,7 @@ export function transformDeclarations(context: TransformationContext): Transform return undefined; } const nameStr = unescapeLeadingUnderscores(p.escapedName); - if (!isIdentifierText(nameStr, ScriptTarget.ESNext)) { + if (!isIdentifierText(nameStr)) { return undefined; // unique symbol or non-identifier name - omit, since there's no syntax that can preserve it } getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); diff --git a/src/compiler/transformers/esDecorators.ts b/src/compiler/transformers/esDecorators.ts index 9f76d6f07be..1559291cb34 100644 --- a/src/compiler/transformers/esDecorators.ts +++ b/src/compiler/transformers/esDecorators.ts @@ -155,7 +155,6 @@ import { PropertyAssignment, PropertyDeclaration, PropertyName, - ScriptTarget, SetAccessorDeclaration, setCommentRange, setEmitFlags, @@ -548,7 +547,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc function getHelperVariableName(node: ClassLikeDeclaration | ClassElement) { let declarationName = node.name && isIdentifier(node.name) && !isGeneratedIdentifier(node.name) ? idText(node.name) : node.name && isPrivateIdentifier(node.name) && !isGeneratedIdentifier(node.name) ? idText(node.name).slice(1) : - node.name && isStringLiteral(node.name) && isIdentifierText(node.name.text, ScriptTarget.ESNext) ? node.name.text : + node.name && isStringLiteral(node.name) && isIdentifierText(node.name.text) ? node.name.text : isClassLike(node) ? "class" : "member"; if (isGetAccessor(node)) declarationName = `get_${declarationName}`; if (isSetAccessor(node)) declarationName = `set_${declarationName}`; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4e7bd184ade..d637d6919ee 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -10811,9 +10811,9 @@ export function isNumericLiteralName(name: string | __String): boolean { } /** @internal */ -export function createPropertyNameNodeForIdentifierOrLiteral(name: string, target: ScriptTarget, singleQuote: boolean, stringNamed: boolean, isMethod: boolean): Identifier | StringLiteral | NumericLiteral { +export function createPropertyNameNodeForIdentifierOrLiteral(name: string, singleQuote: boolean, stringNamed: boolean, isMethod: boolean): Identifier | StringLiteral | NumericLiteral { const isMethodNamedNew = isMethod && name === "new"; - return !isMethodNamedNew && isIdentifierText(name, target) ? factory.createIdentifier(name) : + return !isMethodNamedNew && isIdentifierText(name) ? factory.createIdentifier(name) : !stringNamed && !isMethodNamedNew && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) : factory.createStringLiteral(name, !!singleQuote); } @@ -10927,14 +10927,14 @@ export function isOptionalJSDocPropertyLikeTag(node: Node): boolean { } /** @internal */ -export function canUsePropertyAccess(name: string, languageVersion: ScriptTarget): boolean { +export function canUsePropertyAccess(name: string): boolean { if (name.length === 0) { return false; } const firstChar = name.charCodeAt(0); return firstChar === CharacterCodes.hash ? - name.length > 1 && isIdentifierStart(name.charCodeAt(1), languageVersion) : - isIdentifierStart(firstChar, languageVersion); + name.length > 1 && isIdentifierStart(name.charCodeAt(1)) : + isIdentifierStart(firstChar); } /** @internal */ diff --git a/src/services/codefixes/convertFunctionToEs6Class.ts b/src/services/codefixes/convertFunctionToEs6Class.ts index 56fdaeec81d..a2258d0b323 100644 --- a/src/services/codefixes/convertFunctionToEs6Class.ts +++ b/src/services/codefixes/convertFunctionToEs6Class.ts @@ -13,7 +13,6 @@ import { ClassDeclaration, ClassElement, CodeFixContext, - CompilerOptions, concatenate, copyLeadingComments, Diagnostics, @@ -24,7 +23,6 @@ import { forEach, FunctionDeclaration, FunctionExpression, - getEmitScriptTarget, getNameOfDeclaration, getQuotePreference, getTokenAtPosition, @@ -72,14 +70,14 @@ const errorCodes = [Diagnostics.This_constructor_function_may_be_converted_to_a_ registerCodeFix({ errorCodes, getCodeActions(context: CodeFixContext) { - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start, context.program.getTypeChecker(), context.preferences, context.program.getCompilerOptions())); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start, context.program.getTypeChecker(), context.preferences)); return [createCodeFixAction(fixId, changes, Diagnostics.Convert_function_to_an_ES2015_class, fixId, Diagnostics.Convert_all_constructor_functions_to_classes)]; }, fixIds: [fixId], - getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, err) => doChange(changes, err.file, err.start, context.program.getTypeChecker(), context.preferences, context.program.getCompilerOptions())), + getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, err) => doChange(changes, err.file, err.start, context.program.getTypeChecker(), context.preferences)), }); -function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker, preferences: UserPreferences, compilerOptions: CompilerOptions): void { +function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker, preferences: UserPreferences): void { const ctorSymbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, position))!; if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (SymbolFlags.Function | SymbolFlags.Variable))) { // Bad input @@ -212,7 +210,7 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, po // f.x = expr if (isAccessExpression(memberDeclaration) && (isFunctionExpression(assignmentExpr) || isArrowFunction(assignmentExpr))) { const quotePreference = getQuotePreference(sourceFile, preferences); - const name = tryGetPropertyName(memberDeclaration, compilerOptions, quotePreference); + const name = tryGetPropertyName(memberDeclaration, quotePreference); if (name) { createFunctionLikeExpressionMember(members, assignmentExpr, name); } @@ -320,7 +318,7 @@ function isConstructorAssignment(x: ObjectLiteralElementLike | PropertyAccessExp return false; } -function tryGetPropertyName(node: AccessExpression, compilerOptions: CompilerOptions, quotePreference: QuotePreference): PropertyName | undefined { +function tryGetPropertyName(node: AccessExpression, quotePreference: QuotePreference): PropertyName | undefined { if (isPropertyAccessExpression(node)) { return node.name; } @@ -331,7 +329,7 @@ function tryGetPropertyName(node: AccessExpression, compilerOptions: CompilerOpt } if (isStringLiteralLike(propName)) { - return isIdentifierText(propName.text, getEmitScriptTarget(compilerOptions)) ? factory.createIdentifier(propName.text) + return isIdentifierText(propName.text) ? factory.createIdentifier(propName.text) : isNoSubstitutionTemplateLiteral(propName) ? factory.createStringLiteral(propName.text, quotePreference === QuotePreference.Single) : propName; } diff --git a/src/services/codefixes/convertToEsModule.ts b/src/services/codefixes/convertToEsModule.ts index 02d1a5f9301..6f132f7c3b4 100644 --- a/src/services/codefixes/convertToEsModule.ts +++ b/src/services/codefixes/convertToEsModule.ts @@ -506,7 +506,7 @@ function convertSingleImport( import x from "x"; const [a, b, c] = x; */ - const tmp = makeUniqueName(moduleSpecifierToValidIdentifier(moduleSpecifier.text, target), identifiers); + const tmp = makeUniqueName(moduleSpecifierToValidIdentifier(moduleSpecifier.text), identifiers); return convertedImports([ makeImport(factory.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier, quotePreference), makeConst(/*modifiers*/ undefined, getSynthesizedDeepClone(name), factory.createIdentifier(tmp)), diff --git a/src/services/codefixes/fixAddMissingConstraint.ts b/src/services/codefixes/fixAddMissingConstraint.ts index 34c0bf9ab2b..1d1583d1490 100644 --- a/src/services/codefixes/fixAddMissingConstraint.ts +++ b/src/services/codefixes/fixAddMissingConstraint.ts @@ -16,7 +16,6 @@ import { factory, find, flattenDiagnosticMessageText, - getEmitScriptTarget, getNodeId, getTokenAtPosition, isExpression, @@ -120,10 +119,9 @@ function addMissingConstraint(changes: textChanges.ChangeTracker, program: Progr changes.insertText(sourceFile, declaration.name.end, ` extends ${constraint}`); } else { - const scriptTarget = getEmitScriptTarget(program.getCompilerOptions()); const tracker = getNoopSymbolTrackerWithResolver({ program, host }); const importAdder = createImportAdder(sourceFile, program, preferences, host); - const typeNode = typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, /*internalFlags*/ undefined, tracker); + const typeNode = typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, /*flags*/ undefined, /*internalFlags*/ undefined, tracker); if (typeNode) { changes.replaceNode(sourceFile, declaration, factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default)); importAdder.writeFixes(changes); diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 471cbab82c6..c0bffbb5090 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -41,7 +41,6 @@ import { FunctionExpression, getCheckFlags, getClassLikeDeclarationOfSymbol, - getEmitScriptTarget, getEscapedTextOfJsxAttributeName, getFirstConstructorWithBody, getNodeId, @@ -105,7 +104,6 @@ import { PropertyDeclaration, QuotePreference, ReturnStatement, - ScriptTarget, setParent, Signature, SignatureKind, @@ -348,8 +346,7 @@ function getInfo(sourceFile: SourceFile, tokenPos: number, errorCode: number, ch } if (isIdentifier(token) && isJsxOpeningLikeElement(token.parent)) { - const target = getEmitScriptTarget(program.getCompilerOptions()); - const attributes = getUnmatchedAttributes(checker, target, token.parent); + const attributes = getUnmatchedAttributes(checker, token.parent); if (!length(attributes)) return undefined; return { kind: InfoKind.JsxAttributes, token, attributes, parentDeclaration: token.parent }; } @@ -654,11 +651,10 @@ function addJsxAttributes(changes: textChanges.ChangeTracker, context: CodeFixCo function addObjectLiteralProperties(changes: textChanges.ChangeTracker, context: CodeFixContextBase, info: ObjectLiteralInfo) { const importAdder = createImportAdder(context.sourceFile, context.program, context.preferences, context.host); const quotePreference = getQuotePreference(context.sourceFile, context.preferences); - const target = getEmitScriptTarget(context.program.getCompilerOptions()); const checker = context.program.getTypeChecker(); const props = map(info.properties, prop => { const initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration); - return factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer); + return factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, quotePreference, checker), initializer); }); const options = { leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude, @@ -751,7 +747,7 @@ function isObjectLiteralType(type: Type) { ((getObjectFlags(type) & ObjectFlags.ObjectLiteral) || (type.symbol && tryCast(singleOrUndefined(type.symbol.declarations), isTypeLiteralNode))); } -function getUnmatchedAttributes(checker: TypeChecker, target: ScriptTarget, source: JsxOpeningLikeElement) { +function getUnmatchedAttributes(checker: TypeChecker, source: JsxOpeningLikeElement) { const attrsType = checker.getContextualType(source.attributes); if (attrsType === undefined) return emptyArray; @@ -770,7 +766,7 @@ function getUnmatchedAttributes(checker: TypeChecker, target: ScriptTarget, sour } } } - return filter(targetProps, targetProp => isIdentifierText(targetProp.name, target, LanguageVariant.JSX) && !((targetProp.flags & SymbolFlags.Optional || getCheckFlags(targetProp) & CheckFlags.Partial) || seenNames.has(targetProp.escapedName))); + return filter(targetProps, targetProp => isIdentifierText(targetProp.name, LanguageVariant.JSX) && !((targetProp.flags & SymbolFlags.Optional || getCheckFlags(targetProp) & CheckFlags.Partial) || seenNames.has(targetProp.escapedName))); } function tryGetContainingMethodDeclaration(node: ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode, callExpression: CallExpression) { @@ -781,13 +777,13 @@ function tryGetContainingMethodDeclaration(node: ClassLikeDeclaration | Interfac return declaration && declaration.parent === node ? declaration : undefined; } -function createPropertyNameFromSymbol(symbol: Symbol, target: ScriptTarget, quotePreference: QuotePreference, checker: TypeChecker) { +function createPropertyNameFromSymbol(symbol: Symbol, quotePreference: QuotePreference, checker: TypeChecker) { if (isTransientSymbol(symbol)) { const prop = checker.symbolToNode(symbol, SymbolFlags.Value, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, InternalNodeBuilderFlags.WriteComputedProps); if (prop && isComputedPropertyName(prop)) return prop; } // We're using these nodes as property names in an object literal; no need to quote names when not needed. - return createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === QuotePreference.Single, /*stringNamed*/ false, /*isMethod*/ false); + return createPropertyNameNodeForIdentifierOrLiteral(symbol.name, quotePreference === QuotePreference.Single, /*stringNamed*/ false, /*isMethod*/ false); } function findScope(node: Node) { diff --git a/src/services/codefixes/fixAddMissingParam.ts b/src/services/codefixes/fixAddMissingParam.ts index 65c9cf86158..5940d652287 100644 --- a/src/services/codefixes/fixAddMissingParam.ts +++ b/src/services/codefixes/fixAddMissingParam.ts @@ -304,7 +304,7 @@ function updateParameters( declaration.dotDotDotToken, declaration.name, prev && prev.questionToken ? factory.createToken(SyntaxKind.QuestionToken) : declaration.questionToken, - getParameterType(importAdder, declaration.type, scriptTarget), + getParameterType(importAdder, declaration.type), declaration.initializer, ), ); @@ -347,8 +347,8 @@ function isOptionalPos(declarations: ConvertibleSignatureDeclaration[], pos: num return length(declarations) && some(declarations, d => pos < length(d.parameters) && !!d.parameters[pos] && d.parameters[pos].questionToken === undefined); } -function getParameterType(importAdder: ImportAdder, typeNode: TypeNode | undefined, scriptTarget: ScriptTarget) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); +function getParameterType(importAdder: ImportAdder, typeNode: TypeNode | undefined) { + const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode); if (importableReference) { importSymbols(importAdder, importableReference.symbols); return importableReference.typeNode; diff --git a/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts b/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts index a82ccb01f00..644960c2d10 100644 --- a/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts +++ b/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts @@ -38,7 +38,6 @@ import { findAncestor, FunctionDeclaration, GeneratedIdentifierFlags, - getEmitScriptTarget, getSourceFileOfNode, getSynthesizedDeepClone, getTokenAtPosition, @@ -241,7 +240,6 @@ function withContext( const sourceFile: SourceFile = context.sourceFile; const program = context.program; const typeChecker: TypeChecker = program.getTypeChecker(); - const scriptTarget = getEmitScriptTarget(program.getCompilerOptions()); const importAdder = createImportAdder(context.sourceFile, context.program, context.preferences, context.host); const fixedNodes = new Set(); const expandoPropertiesAdded = new Set(); @@ -286,7 +284,7 @@ function withContext( const newProperties = []; for (const symbol of elements) { // non-valid names will not end up in declaration emit - if (!isIdentifierText(symbol.name, getEmitScriptTarget(program.getCompilerOptions()))) continue; + if (!isIdentifierText(symbol.name)) continue; // already has an existing declaration if (symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration)) continue; @@ -1111,13 +1109,13 @@ function withContext( if (!minimizedTypeNode) { return undefined; } - const result = typeNodeToAutoImportableTypeNode(minimizedTypeNode, importAdder, scriptTarget); + const result = typeNodeToAutoImportableTypeNode(minimizedTypeNode, importAdder); return isTruncated ? factory.createKeywordTypeNode(SyntaxKind.AnyKeyword) : result; } function typePredicateToTypeNode(typePredicate: TypePredicate, enclosingDeclaration: Node, flags = NodeBuilderFlags.None): TypeNode | undefined { let isTruncated = false; - const result = typePredicateToAutoImportableTypeNode(typeChecker, importAdder, typePredicate, enclosingDeclaration, scriptTarget, declarationEmitNodeBuilderFlags | flags, declarationEmitInternalNodeBuilderFlags, { + const result = typePredicateToAutoImportableTypeNode(typeChecker, importAdder, typePredicate, enclosingDeclaration, declarationEmitNodeBuilderFlags | flags, declarationEmitInternalNodeBuilderFlags, { moduleResolverHost: program, trackSymbol() { return true; diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 21a32bd00c4..e2974cbca3e 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -10,7 +10,6 @@ import { factory, findAncestor, getEffectiveBaseTypeNode, - getEmitScriptTarget, getMeaningFromLocation, getTextOfNode, getTokenAtPosition, @@ -33,7 +32,6 @@ import { isStringLiteralLike, Node, NodeFlags, - ScriptTarget, SemanticMeaning, SourceFile, Symbol, @@ -67,16 +65,14 @@ registerCodeFix({ const info = getInfo(sourceFile, context.span.start, context, errorCode); if (!info) return undefined; const { node, suggestedSymbol } = info; - const target = getEmitScriptTarget(context.host.getCompilationSettings()); - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestedSymbol, target)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestedSymbol)); return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId, Diagnostics.Fix_all_detected_spelling_errors)]; }, fixIds: [fixId], getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => { const info = getInfo(diag.file, diag.start, context, diag.code); - const target = getEmitScriptTarget(context.host.getCompilationSettings()); - if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target); + if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol); }), }); @@ -147,9 +143,9 @@ function getInfo(sourceFile: SourceFile, pos: number, context: CodeFixContextBas return suggestedSymbol === undefined ? undefined : { node, suggestedSymbol }; } -function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: Node, suggestedSymbol: Symbol, target: ScriptTarget) { +function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: Node, suggestedSymbol: Symbol) { const suggestion = symbolName(suggestedSymbol); - if (!isIdentifierText(suggestion, target) && isPropertyAccessExpression(node.parent)) { + if (!isIdentifierText(suggestion) && isPropertyAccessExpression(node.parent)) { const valDecl = suggestedSymbol.valueDeclaration; if (valDecl && isNamedDeclaration(valDecl) && isPrivateIdentifier(valDecl.name)) { changes.replaceNode(sourceFile, node, factory.createIdentifier(suggestion)); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 107f954def4..a78d92f23a0 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -188,7 +188,6 @@ export function addNewNodeForMemberSymbol( const declarations = symbol.getDeclarations(); const declaration = firstOrUndefined(declarations); const checker = context.program.getTypeChecker(); - const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions()); /** * (#49811) @@ -227,7 +226,7 @@ export function addNewNodeForMemberSymbol( case SyntaxKind.PropertyDeclaration: let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, InternalNodeBuilderFlags.AllowUnresolvedNames, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode); if (importableReference) { typeNode = importableReference.typeNode; importSymbols(importAdder, importableReference.symbols); @@ -250,7 +249,7 @@ export function addNewNodeForMemberSymbol( ? [allAccessors.firstAccessor, allAccessors.secondAccessor] : [allAccessors.firstAccessor]; if (importAdder) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode); if (importableReference) { typeNode = importableReference.typeNode; importSymbols(importAdder, importableReference.symbols); @@ -392,7 +391,6 @@ export function createSignatureDeclarationFromSignature( ): FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | undefined { const program = context.program; const checker = program.getTypeChecker(); - const scriptTarget = getEmitScriptTarget(program.getCompilerOptions()); const isJs = isInJSFile(enclosingDeclaration); const flags = NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType @@ -412,14 +410,14 @@ export function createSignatureDeclarationFromSignature( let constraint = typeParameterDecl.constraint; let defaultType = typeParameterDecl.default; if (constraint) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(constraint, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(constraint); if (importableReference) { constraint = importableReference.typeNode; importSymbols(importAdder, importableReference.symbols); } } if (defaultType) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(defaultType, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(defaultType); if (importableReference) { defaultType = importableReference.typeNode; importSymbols(importAdder, importableReference.symbols); @@ -440,7 +438,7 @@ export function createSignatureDeclarationFromSignature( const newParameters = sameMap(parameters, parameterDecl => { let type = isJs ? undefined : parameterDecl.type; if (type) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(type, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(type); if (importableReference) { type = importableReference.typeNode; importSymbols(importAdder, importableReference.symbols); @@ -460,7 +458,7 @@ export function createSignatureDeclarationFromSignature( parameters = setTextRange(factory.createNodeArray(newParameters, parameters.hasTrailingComma), parameters); } if (type) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(type, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(type); if (importableReference) { type = importableReference.typeNode; importSymbols(importAdder, importableReference.symbols); @@ -596,17 +594,17 @@ function createTypeParameterName(index: number) { } /** @internal */ -export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, type: Type, contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined { +export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, type: Type, contextNode: Node | undefined, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined { const typeNode = checker.typeToTypeNode(type, contextNode, flags, internalFlags, tracker); if (!typeNode) { return undefined; } - return typeNodeToAutoImportableTypeNode(typeNode, importAdder, scriptTarget); + return typeNodeToAutoImportableTypeNode(typeNode, importAdder); } /** @internal */ -export function typeNodeToAutoImportableTypeNode(typeNode: TypeNode, importAdder: ImportAdder, scriptTarget: ScriptTarget): TypeNode | undefined { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); +export function typeNodeToAutoImportableTypeNode(typeNode: TypeNode, importAdder: ImportAdder): TypeNode | undefined { + const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode); if (importableReference) { importSymbols(importAdder, importableReference.symbols); typeNode = importableReference.typeNode; @@ -651,10 +649,10 @@ export function typeToMinimizedReferenceType(checker: TypeChecker, type: Type, c } /** @internal */ -export function typePredicateToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, typePredicate: TypePredicate, contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined { +export function typePredicateToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, typePredicate: TypePredicate, contextNode: Node | undefined, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined { let typePredicateNode = checker.typePredicateToTypePredicateNode(typePredicate, contextNode, flags, internalFlags, tracker); if (typePredicateNode?.type && isImportTypeNode(typePredicateNode.type)) { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(typePredicateNode.type, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(typePredicateNode.type); if (importableReference) { importSymbols(importAdder, importableReference.symbols); typePredicateNode = factory.updateTypePredicateNode(typePredicateNode, typePredicateNode.assertsModifier, typePredicateNode.parameterName, importableReference.typeNode); @@ -715,7 +713,7 @@ function getArgumentTypesAndTypeParameters(checker: TypeChecker, importAdder: Im // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" const widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType); - const argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, internalFlags, tracker); + const argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, flags, internalFlags, tracker); if (!argumentTypeNode) { continue; } @@ -733,7 +731,7 @@ function getArgumentTypesAndTypeParameters(checker: TypeChecker, importAdder: Im // We instead want to output: // function added(value: T) { ... } const instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint) - ? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, internalFlags, tracker) + ? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, flags, internalFlags, tracker) : undefined; if (argumentTypeParameter) { @@ -950,7 +948,7 @@ function findJsonProperty(obj: ObjectLiteralExpression, name: string): PropertyA * * @internal */ -export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNode | undefined, scriptTarget: ScriptTarget): { +export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNode | undefined): { typeNode: TypeNode; symbols: Symbol[]; } | undefined { @@ -970,7 +968,7 @@ export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNo // it can't refer to reserved internal symbol names and such return visitEachChild(node, visit, /*context*/ undefined); } - const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget); + const name = getNameForExportedSymbol(firstIdentifier.symbol); const qualifier = name !== firstIdentifier.text ? replaceFirstIdentifierOfEntityName(node.qualifier, factory.createIdentifier(name)) : node.qualifier; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index c59c53677db..553a96e3ae8 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -282,7 +282,7 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog function addImportFromExportedSymbol(exportedSymbol: Symbol, isValidTypeOnlyUseSite?: boolean, referenceImport?: ImportOrRequireAliasDeclaration) { const moduleSymbol = Debug.checkDefined(exportedSymbol.parent, "Expected exported symbol to have module symbol as parent"); - const symbolName = getNameForExportedSymbol(exportedSymbol, getEmitScriptTarget(compilerOptions)); + const symbolName = getNameForExportedSymbol(exportedSymbol); const checker = program.getTypeChecker(); const symbol = checker.getMergedSymbol(skipAlias(exportedSymbol, checker)); const exportInfo = getAllExportInfoForSymbol(sourceFile, symbol, symbolName, moduleSymbol, /*preferCapitalized*/ false, program, host, preferences, cancellationToken); @@ -1296,7 +1296,6 @@ function getNewImportFixes( } namespacePrefix ||= moduleSymbolToValidIdentifier( exportInfo.moduleSymbol, - getEmitScriptTarget(compilerOptions), /*forceCapitalize*/ false, ); qualification = { namespacePrefix, usagePosition }; diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 620542686ac..188ebbda22a 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -34,7 +34,6 @@ import { forEach, forEachEntry, getContainingFunction, - getEmitScriptTarget, getJSDocType, getNameOfDeclaration, getObjectFlags, @@ -85,7 +84,6 @@ import { PropertyName, PropertySignature, returnTrue, - ScriptTarget, SetAccessorDeclaration, setEmitFlags, ShorthandPropertyAssignment, @@ -423,7 +421,7 @@ function annotate(changes: textChanges.ChangeTracker, importAdder: ImportAdder, const typeTag = isGetAccessorDeclaration(declaration) ? factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); changes.addJSDocTags(sourceFile, parent, [typeTag]); } - else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, getEmitScriptTarget(program.getCompilerOptions()))) { + else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder)) { changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); } } @@ -435,9 +433,8 @@ function tryReplaceImportTypeNodeWithAutoImport( sourceFile: SourceFile, changes: textChanges.ChangeTracker, importAdder: ImportAdder, - scriptTarget: ScriptTarget, ): boolean { - const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); + const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode); if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeNode)) { forEach(importableReference.symbols, s => importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true)); return true; diff --git a/src/services/completions.ts b/src/services/completions.ts index 30e9ad40bf3..b0000a28651 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1461,7 +1461,7 @@ function getExhaustiveCaseSnippets( } tracker.addValue(enumValue); } - const typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock, target); + const typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock); if (!typeNode) { return undefined; } @@ -1564,7 +1564,7 @@ function entityNameToExpression(entityName: EntityName, languageVersion: ScriptT return entityName; } const unescapedName = unescapeLeadingUnderscores(entityName.right.escapedText); - if (canUsePropertyAccess(unescapedName, languageVersion)) { + if (canUsePropertyAccess(unescapedName)) { return factory.createPropertyAccessExpression( entityNameToExpression(entityName.left, languageVersion, quotePreference), unescapedName, @@ -1655,7 +1655,7 @@ function getJSCompletionEntries( return; } const realName = unescapeLeadingUnderscores(name); - if (!uniqueNames.has(realName) && isIdentifierText(realName, target)) { + if (!uniqueNames.has(realName) && isIdentifierText(realName)) { uniqueNames.add(realName); insertSorted(entries, { name: realName, @@ -1888,8 +1888,7 @@ function createCompletionEntry( const parentNamedImportOrExport = findAncestor(location, isNamedImportsOrExports); if (parentNamedImportOrExport) { - const languageVersion = getEmitScriptTarget(host.getCompilationSettings()); - if (!isIdentifierText(name, languageVersion)) { + if (!isIdentifierText(name)) { insertText = quotePropertyName(sourceFile, preferences, name); if (parentNamedImportOrExport.kind === SyntaxKind.NamedImports) { @@ -1898,7 +1897,7 @@ function createCompletionEntry( scanner.setText(sourceFile.text); scanner.resetTokenState(position); if (!(scanner.scan() === SyntaxKind.AsKeyword && scanner.scan() === SyntaxKind.Identifier)) { - insertText += " as " + generateIdentifierForArbitraryString(name, languageVersion); + insertText += " as " + generateIdentifierForArbitraryString(name); } } } @@ -1942,7 +1941,7 @@ function createCompletionEntry( }; } -function generateIdentifierForArbitraryString(text: string, languageVersion: ScriptTarget | undefined): string { +function generateIdentifierForArbitraryString(text: string): string { let needsUnderscore = false; let identifier = ""; let ch: number | undefined; @@ -1950,7 +1949,7 @@ function generateIdentifierForArbitraryString(text: string, languageVersion: Scr // Convert "(example, text)" into "_example_text_" for (let i = 0; i < text.length; i += ch !== undefined && ch >= 0x10000 ? 2 : 1) { ch = text.codePointAt(i); - if (ch !== undefined && (i === 0 ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch !== undefined && (i === 0 ? isIdentifierStart(ch) : isIdentifierPart(ch))) { if (needsUnderscore) identifier += "_"; identifier += String.fromCodePoint(ch); needsUnderscore = false; @@ -4165,7 +4164,7 @@ function getCompletionData( sourceFile.path, /*preferCapitalized*/ isRightOfOpenTag, (symbolName, targetFlags) => { - if (!isIdentifierText(symbolName, getEmitScriptTarget(host.getCompilationSettings()))) return false; + if (!isIdentifierText(symbolName)) return false; if (!detailsEntryId && isStringANonContextualKeyword(symbolName)) return false; if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & SymbolFlags.Value)) return false; if (isTypeOnlyLocation && !(targetFlags & (SymbolFlags.Module | SymbolFlags.Type))) return false; @@ -5413,7 +5412,7 @@ function getCompletionEntryDisplayNameForSymbol( } const validNameResult: CompletionEntryDisplayNameForSymbol = { name, needsConvertPropertyAccess: false }; - if (isIdentifierText(name, target, jsxIdentifierExpected ? LanguageVariant.JSX : LanguageVariant.Standard) || symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (isIdentifierText(name, jsxIdentifierExpected ? LanguageVariant.JSX : LanguageVariant.Standard) || symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } if (symbol.flags & SymbolFlags.Alias) { diff --git a/src/services/exportInfoMap.ts b/src/services/exportInfoMap.ts index dfd00ce2e91..5c1e1676b1c 100644 --- a/src/services/exportInfoMap.ts +++ b/src/services/exportInfoMap.ts @@ -660,8 +660,8 @@ export function forEachNameOfDefaultExport(defaultExport: Symbol, checker: Ty for (const symbol of chain ?? emptyArray) { if (symbol.parent && isExternalModuleSymbol(symbol.parent)) { const final = cb( - moduleSymbolToValidIdentifier(symbol.parent, scriptTarget, /*forceCapitalize*/ false), - moduleSymbolToValidIdentifier(symbol.parent, scriptTarget, /*forceCapitalize*/ true), + moduleSymbolToValidIdentifier(symbol.parent, /*forceCapitalize*/ false), + moduleSymbolToValidIdentifier(symbol.parent, /*forceCapitalize*/ true), ); if (final) return final; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index ea1f164f84f..868be935626 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -235,7 +235,6 @@ import { ReferenceEntry, RenameLocation, ScriptElementKind, - ScriptTarget, SemanticMeaning, SetAccessorDeclaration, SignatureDeclaration, @@ -1804,8 +1803,8 @@ export namespace Core { const endPosition = position + symbolNameLength; if ( - (position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && - (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest)) + (position === 0 || !isIdentifierPart(text.charCodeAt(position - 1))) && + (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition))) ) { // Found a real match. Keep searching. positions.push(position); diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts index d79def83639..8d1bb4e7c75 100644 --- a/src/services/inlayHints.ts +++ b/src/services/inlayHints.ts @@ -22,7 +22,6 @@ import { GetAccessorDeclaration, getEffectiveReturnTypeNode, getEffectiveTypeAnnotationNode, - getEmitScriptTarget, getLanguageVariant, getLeadingCommentRanges, getNameOfDeclaration, @@ -146,7 +145,6 @@ function shouldUseInteractiveInlayHints(preferences: UserPreferences) { export function provideInlayHints(context: InlayHintsContext): InlayHint[] { const { file, program, span, cancellationToken, preferences } = context; const sourceFileText = file.text; - const compilerOptions = program.getCompilerOptions(); const quotePreference = getQuotePreference(file, preferences); const checker = program.getTypeChecker(); @@ -353,7 +351,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] { } function leadingCommentsContainsParameterName(node: Node, name: string) { - if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions), getLanguageVariant(file.scriptKind))) { + if (!isIdentifierText(name, getLanguageVariant(file.scriptKind))) { return false; } diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index f146e8d32b4..33b0ccfeeac 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -7,7 +7,6 @@ import { isUnicodeIdentifierStart, last, min, - ScriptTarget, startsWith, TextSpan, } from "./_namespaces/ts.js"; @@ -385,7 +384,7 @@ function isUpperCaseLetter(ch: number) { return true; } - if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch, ScriptTarget.Latest)) { + if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch)) { return false; } @@ -401,7 +400,7 @@ function isLowerCaseLetter(ch: number) { return true; } - if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch, ScriptTarget.Latest)) { + if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch)) { return false; } diff --git a/src/services/refactors/convertImport.ts b/src/services/refactors/convertImport.ts index 1b21d2d5beb..8e766c40faf 100644 --- a/src/services/refactors/convertImport.ts +++ b/src/services/refactors/convertImport.ts @@ -37,7 +37,6 @@ import { QualifiedName, RefactorContext, RefactorEditInfo, - ScriptTarget, some, SourceFile, Symbol, @@ -222,7 +221,7 @@ export function doChangeNamedToNamespaceOrDefault(sourceFile: SourceFile, progra toConvertSymbols.add(symbol); } }); - const preferredName = moduleSpecifier && isStringLiteral(moduleSpecifier) ? moduleSpecifierToValidIdentifier(moduleSpecifier.text, ScriptTarget.ESNext) : "module"; + const preferredName = moduleSpecifier && isStringLiteral(moduleSpecifier) ? moduleSpecifierToValidIdentifier(moduleSpecifier.text) : "module"; function hasNamespaceNameConflict(namedImport: ImportSpecifier): boolean { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 2d59e42c433..07bf52338d2 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -45,7 +45,6 @@ import { getContainingClass, getContainingFunction, getEffectiveTypeParameterDeclarations, - getEmitScriptTarget, getEnclosingBlockScopeContainer, getLineAndCharacterOfPosition, getLocaleSpecificMessage, @@ -1043,7 +1042,6 @@ function extractFunctionInScope( context: RefactorContext, ): RefactorEditInfo { const checker = context.program.getTypeChecker(); - const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions()); const importAdder = codefix.createImportAdder(context.file, context.program, context.preferences, context.host); // Make a unique name for the extracted function @@ -1063,7 +1061,7 @@ function extractFunctionInScope( let type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, NodeBuilderFlags.NoTruncation, InternalNodeBuilderFlags.AllowUnresolvedNames); + typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, NodeBuilderFlags.NoTruncation, InternalNodeBuilderFlags.AllowUnresolvedNames); } const paramDecl = factory.createParameterDeclaration( diff --git a/src/services/refactors/helpers.ts b/src/services/refactors/helpers.ts index 9779b8559f8..a5872ac907a 100644 --- a/src/services/refactors/helpers.ts +++ b/src/services/refactors/helpers.ts @@ -89,5 +89,5 @@ export function addTargetFileImports( } }); - addImportsForMovedSymbols(targetFileImportsFromOldFile, oldFile.fileName, importAdder, program); + addImportsForMovedSymbols(targetFileImportsFromOldFile, oldFile.fileName, importAdder); } diff --git a/src/services/refactors/moveToFile.ts b/src/services/refactors/moveToFile.ts index 18fd421d6d0..5950ba4a83b 100644 --- a/src/services/refactors/moveToFile.ts +++ b/src/services/refactors/moveToFile.ts @@ -50,7 +50,6 @@ import { GetCanonicalFileName, getDecorators, getDirectoryPath, - getEmitScriptTarget, getLineAndCharacterOfPosition, getLocaleSpecificMessage, getModifiers, @@ -135,7 +134,6 @@ import { RefactorEditInfo, RequireOrImportCall, resolvePath, - ScriptTarget, skipAlias, some, SourceFile, @@ -253,7 +251,7 @@ export function getNewStatementsAndRemoveFromOldFile( const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(targetFile.fileName, program, host, !!oldFile.commonJsModuleIndicator); const quotePreference = getQuotePreference(oldFile, preferences); - addImportsForMovedSymbols(usage.oldFileImportsFromTargetFile, targetFile.fileName, importAdderForOldFile, program); + addImportsForMovedSymbols(usage.oldFileImportsFromTargetFile, targetFile.fileName, importAdderForOldFile); deleteUnusedOldImports(oldFile, toMove.all, usage.unusedImportsFromOldFile, importAdderForOldFile); importAdderForOldFile.writeFixes(changes, quotePreference); deleteMovedStatements(oldFile, toMove.ranges, changes); @@ -396,7 +394,7 @@ function updateNamespaceLikeImport( oldImportNode: SupportedImport, quotePreference: QuotePreference, ): void { - const preferredNewNamespaceName = moduleSpecifierToValidIdentifier(newModuleSpecifier, ScriptTarget.ESNext); + const preferredNewNamespaceName = moduleSpecifierToValidIdentifier(newModuleSpecifier); let needUniqueName = false; const toChange: Identifier[] = []; FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, ref => { @@ -512,10 +510,9 @@ export function addImportsForMovedSymbols( symbols: Map, targetFileName: string, importAdder: codefix.ImportAdder, - program: Program, ): void { for (const [symbol, isValidTypeOnlyUseSite] of symbols) { - const symbolName = getNameForExportedSymbol(symbol, getEmitScriptTarget(program.getCompilerOptions())); + const symbolName = getNameForExportedSymbol(symbol); const exportKind = symbol.name === "default" && symbol.parent ? ExportKind.Default : ExportKind.Named; importAdder.addImportForNonExistentExport(symbolName, targetFileName, exportKind, symbol.flags, isValidTypeOnlyUseSite); } diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 63cac4d49cc..80e360d980a 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -1375,7 +1375,7 @@ function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan const offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. const length = text.length - offset; - return length === 0 || isIdentifierText(text.substr(offset, length), ScriptTarget.ESNext) ? undefined : createTextSpan(textStart + offset, length); + return length === 0 || isIdentifierText(text.substr(offset, length)) ? undefined : createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 83db802709f..ae2fa0ea48d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -4000,14 +4000,14 @@ export function firstOrOnly(valueOrArray: T | readonly T[]): T { * instead, which searches for names of re-exported defaults/namespaces in target files. * @internal */ -export function getNameForExportedSymbol(symbol: Symbol, scriptTarget: ScriptTarget | undefined, preferCapitalized?: boolean): string { +export function getNameForExportedSymbol(symbol: Symbol, preferCapitalized?: boolean): string { if (symbol.escapedName === InternalSymbolName.ExportEquals || symbol.escapedName === InternalSymbolName.Default) { // Names for default exports: // - export default foo => foo // - export { foo as default } => foo // - export default 0 => filename converted to camelCase return getDefaultLikeExportNameFromDeclaration(symbol) - || moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized); + || moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), !!preferCapitalized); } return symbol.name; } @@ -4054,17 +4054,17 @@ function getSymbolParentOrFail(symbol: Symbol) { } /** @internal */ -export function moduleSymbolToValidIdentifier(moduleSymbol: Symbol, target: ScriptTarget | undefined, forceCapitalize: boolean): string { - return moduleSpecifierToValidIdentifier(removeFileExtension(stripQuotes(moduleSymbol.name)), target, forceCapitalize); +export function moduleSymbolToValidIdentifier(moduleSymbol: Symbol, forceCapitalize: boolean): string { + return moduleSpecifierToValidIdentifier(removeFileExtension(stripQuotes(moduleSymbol.name)), forceCapitalize); } /** @internal */ -export function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target: ScriptTarget | undefined, forceCapitalize?: boolean): string { +export function moduleSpecifierToValidIdentifier(moduleSpecifier: string, forceCapitalize?: boolean): string { const baseName = getBaseFileName(removeSuffix(removeFileExtension(moduleSpecifier), "/index")); let res = ""; let lastCharWasValid = true; const firstCharCode = baseName.charCodeAt(0); - if (isIdentifierStart(firstCharCode, target)) { + if (isIdentifierStart(firstCharCode)) { res += String.fromCharCode(firstCharCode); if (forceCapitalize) { res = res.toUpperCase(); @@ -4075,7 +4075,7 @@ export function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target } for (let i = 1; i < baseName.length; i++) { const ch = baseName.charCodeAt(i); - const isValid = isIdentifierPart(ch, target); + const isValid = isIdentifierPart(ch); if (isValid) { let char = String.fromCharCode(ch); if (!lastCharWasValid) { diff --git a/src/testRunner/unittests/services/extract/helpers.ts b/src/testRunner/unittests/services/extract/helpers.ts index b733b89f50c..e623acf1fa9 100644 --- a/src/testRunner/unittests/services/extract/helpers.ts +++ b/src/testRunner/unittests/services/extract/helpers.ts @@ -88,7 +88,7 @@ export function extractTest(source: string): Test { text += source.substring(lastPos, pos); function consumeIdentifier() { - while (ts.isIdentifierPart(source.charCodeAt(pos), ts.ScriptTarget.Latest)) { + while (ts.isIdentifierPart(source.charCodeAt(pos))) { pos++; } } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 216fc899f6a..27ddc4bcd08 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -8470,8 +8470,8 @@ declare namespace ts { function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string | undefined; - function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean; - function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean; + function isIdentifierStart(ch: number): boolean; + function isIdentifierPart(ch: number, identifierVariant?: LanguageVariant): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, textInitial?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; type ErrorCallback = (message: DiagnosticMessage, length: number, arg0?: any) => void; interface Scanner { diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt index d0482948aa8..de53e2b1953 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt @@ -1,161 +1,37 @@ -error TS-1: Pre-emit (44) and post-emit (45) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! -astralAsSurrogatePair.ts(1,11): error TS1127: Invalid character. -astralAsSurrogatePair.ts(1,14): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'as'. astralAsSurrogatePair.ts(1,17): error TS1127: Invalid character. astralAsSurrogatePair.ts(1,18): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. astralAsSurrogatePair.ts(1,23): error TS1127: Invalid character. astralAsSurrogatePair.ts(1,24): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. -extendedEscapesForAstralsInVarsAndClasses.ts(2,5): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(2,7): error TS1134: Variable declaration expected. -extendedEscapesForAstralsInVarsAndClasses.ts(3,5): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(3,7): error TS1005: ',' expected. -extendedEscapesForAstralsInVarsAndClasses.ts(3,11): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(6,5): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(6,8): error TS1128: Declaration or statement expected. -extendedEscapesForAstralsInVarsAndClasses.ts(9,5): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(9,6): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(9,11): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(9,15): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the whole assignment in parentheses. -extendedEscapesForAstralsInVarsAndClasses.ts(13,5): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(13,6): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(13,7): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -extendedEscapesForAstralsInVarsAndClasses.ts(13,11): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(13,14): error TS1128: Declaration or statement expected. -extendedEscapesForAstralsInVarsAndClasses.ts(14,5): error TS2304: Cannot find name 'constructor'. -extendedEscapesForAstralsInVarsAndClasses.ts(14,19): error TS1005: ';' expected. -extendedEscapesForAstralsInVarsAndClasses.ts(15,9): error TS2532: Object is possibly 'undefined'. -extendedEscapesForAstralsInVarsAndClasses.ts(15,14): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(15,15): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(15,20): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(15,24): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the whole assignment in parentheses. -extendedEscapesForAstralsInVarsAndClasses.ts(17,5): error TS2304: Cannot find name 'methodA'. -extendedEscapesForAstralsInVarsAndClasses.ts(17,15): error TS1005: ';' expected. -extendedEscapesForAstralsInVarsAndClasses.ts(18,21): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(20,1): error TS1128: Declaration or statement expected. -extendedEscapesForAstralsInVarsAndClasses.ts(22,13): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(22,16): error TS1134: Variable declaration expected. -extendedEscapesForAstralsInVarsAndClasses.ts(22,18): error TS1389: 'new' is not allowed as a variable declaration name. -extendedEscapesForAstralsInVarsAndClasses.ts(22,28): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(22,29): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(22,34): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(22,50): error TS2339: Property 'methodA' does not exist on type 'Foo'. -extendedEscapesForAstralsInVarsAndClasses.ts(24,2): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(24,3): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(24,8): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration or statement expected. -!!! error TS-1: Pre-emit (44) and post-emit (45) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! -!!! related TS-1: The excess diagnostics are: -!!! related TS2532 extendedEscapesForAstralsInVarsAndClasses.ts:18:16: Object is possibly 'undefined'. -==== extendedEscapesForAstralsInVarsAndClasses.ts (38 errors) ==== +==== extendedEscapesForAstralsInVarsAndClasses.ts (0 errors) ==== // U+102A7 CARIAN LETTER A2 var 𐊧: string; - ~~ -!!! error TS1127: Invalid character. - ~ -!!! error TS1134: Variable declaration expected. var \u{102A7}: string; - -!!! error TS1127: Invalid character. - ~ -!!! error TS1005: ',' expected. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. if (Math.random()) { 𐊧 = "hello"; - ~~ -!!! error TS1127: Invalid character. - ~ -!!! error TS1128: Declaration or statement expected. } else { \u{102A7} = "hallo"; - -!!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. - ~ -!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the whole assignment in parentheses. } class Foo { \u{102A7}: string; - -!!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. - ~ -!!! error TS1128: Declaration or statement expected. constructor() { - ~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'constructor'. - ~ -!!! error TS1005: ';' expected. this.\u{102A7} = " world"; - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - -!!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. - ~ -!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the whole assignment in parentheses. } methodA() { - ~~~~~~~ -!!! error TS2304: Cannot find name 'methodA'. - ~ -!!! error TS1005: ';' expected. return this.𐊧; - ~~ -!!! error TS1127: Invalid character. } } - ~ -!!! error TS1128: Declaration or statement expected. export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); - ~~ -!!! error TS1127: Invalid character. - ~ -!!! error TS1134: Variable declaration expected. - ~~~ -!!! error TS1389: 'new' is not allowed as a variable declaration name. - -!!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. - ~~~~~~~ -!!! error TS2339: Property 'methodA' does not exist on type 'Foo'. _\u{102A7} += "!"; - -!!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. - ~~ -!!! error TS1128: Declaration or statement expected. -==== astralAsSurrogatePair.ts (6 errors) ==== +==== astralAsSurrogatePair.ts (4 errors) ==== import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; - ~~ -!!! error TS1127: Invalid character. - ~~ -!!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'as'. !!! error TS1127: Invalid character. ~~~~~ diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js index 10d5993bd37..fb37c4b3387 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js @@ -32,55 +32,24 @@ import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClass //// [extendedEscapesForAstralsInVarsAndClasses.js] // U+102A7 CARIAN LETTER A2 -var string; -var u, { 102: A7 }; +var 𐊧; +var \u{102A7}; if (Math.random()) { - "hello"; + 𐊧 = "hello"; } else { - u; - { - 102; - A7; - } - "hallo"; + \u{102A7} = "hallo"; } class Foo { -} -{ - 102; - A7; -} -string; -constructor(); -{ - this.; - u; - { - 102; - A7; + constructor() { + this.\u{102A7} = " world"; + } + methodA() { + return this.𐊧; } - " world"; } -methodA(); -{ - return this.𐊧; -} -export var _; -new Foo().; -u; -{ - 102; - A7; -} -+new Foo().methodA(); -_; -u; -{ - 102; - A7; -} -"!"; +export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); +_\u{102A7} += "!"; //# sourceMappingURL=extendedEscapesForAstralsInVarsAndClasses.js.map //// [astralAsSurrogatePair.js] export {}; diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map index 6388121b938..8eb7b3f65ea 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map @@ -1,6 +1,6 @@ //// [extendedEscapesForAstralsInVarsAndClasses.js.map] -{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,IAAQ,MAAM,CAAC;AACf,IAAK,CAAC,EAAA,EAAC,GAAG,EAAA,EAAE,EAAS,CAAC;AAEtB,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IACX,OAAO,CAAC;AACjB,CAAC;KACI,CAAC;IACD,CAAC,CAAA;IAAA,CAAC;QAAA,GAAG,CAAA;QAAA,EAAE,CAAA;IAAA,CAAC;IAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,GAAG;CACH;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAE,MAAM,CAAC;AAClB,WAAW,EAAE,CAAA;AAAC,CAAC;IACX,IAAI,CAAC,CAAA;IAAC,CAAC,CAAA;IAAA,CAAC;QAAA,GAAG,CAAA;QAAA,EAAE,CAAA;IAAA,CAAC;IAAG,QAAQ,CAAC;AAC9B,CAAC;AACD,OAAO,EAAE,CAAA;AAAC,CAAC;IACP,OAAO,IAAI,CAAC,EAAE,CAAC;AACnB,CAAC;AAGL,MAAM,CAAC,IAAI,CAAK,CAAA;AAAC,IAAI,GAAG,EAAE,CAAC,CAAA;AAAC,CAAC,CAAA;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAC,CAAE,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE3D,CAAC,CAAA;AAAC,CAAC,CAAA;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAI,GAAG,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyDQp2YXIgc3RyaW5nOw0KdmFyIHUsIHsgMTAyOiBBNyB9Ow0KaWYgKE1hdGgucmFuZG9tKCkpIHsNCiAgICAiaGVsbG8iOw0KfQ0KZWxzZSB7DQogICAgdTsNCiAgICB7DQogICAgICAgIDEwMjsNCiAgICAgICAgQTc7DQogICAgfQ0KICAgICJoYWxsbyI7DQp9DQpjbGFzcyBGb28gew0KfQ0Kew0KICAgIDEwMjsNCiAgICBBNzsNCn0NCnN0cmluZzsNCmNvbnN0cnVjdG9yKCk7DQp7DQogICAgdGhpcy47DQogICAgdTsNCiAgICB7DQogICAgICAgIDEwMjsNCiAgICAgICAgQTc7DQogICAgfQ0KICAgICIgd29ybGQiOw0KfQ0KbWV0aG9kQSgpOw0Kew0KICAgIHJldHVybiB0aGlzLu2ggO26pzsNCn0NCmV4cG9ydCB2YXIgXzsNCm5ldyBGb28oKS47DQp1Ow0Kew0KICAgIDEwMjsNCiAgICBBNzsNCn0NCituZXcgRm9vKCkubWV0aG9kQSgpOw0KXzsNCnU7DQp7DQogICAgMTAyOw0KICAgIEE3Ow0KfQ0KIiEiOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZXh0ZW5kZWRFc2NhcGVzRm9yQXN0cmFsc0luVmFyc0FuZENsYXNzZXMuanMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5kZWRFc2NhcGVzRm9yQXN0cmFsc0luVmFyc0FuZENsYXNzZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJleHRlbmRlZEVzY2FwZXNGb3JBc3RyYWxzSW5WYXJzQW5kQ2xhc3Nlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQkFBMkI7QUFDM0IsSUFBUSxNQUFNLENBQUM7QUFDZixJQUFLLENBQUMsRUFBQSxFQUFDLEdBQUcsRUFBQSxFQUFFLEVBQVMsQ0FBQztBQUV0QixJQUFJLElBQUksQ0FBQyxNQUFNLEVBQUUsRUFBRSxDQUFDO0lBQ1gsT0FBTyxDQUFDO0FBQ2pCLENBQUM7S0FDSSxDQUFDO0lBQ0QsQ0FBQyxDQUFBO0lBQUEsQ0FBQztRQUFBLEdBQUcsQ0FBQTtRQUFBLEVBQUUsQ0FBQTtJQUFBLENBQUM7SUFBRyxPQUFPLENBQUM7QUFDeEIsQ0FBQztBQUVELE1BQU0sR0FBRztDQUNIO0FBQUEsQ0FBQztJQUFBLEdBQUcsQ0FBQTtJQUFBLEVBQUUsQ0FBQTtBQUFBLENBQUM7QUFBRSxNQUFNLENBQUM7QUFDbEIsV0FBVyxFQUFFLENBQUE7QUFBQyxDQUFDO0lBQ1gsSUFBSSxDQUFDLENBQUE7SUFBQyxDQUFDLENBQUE7SUFBQSxDQUFDO1FBQUEsR0FBRyxDQUFBO1FBQUEsRUFBRSxDQUFBO0lBQUEsQ0FBQztJQUFHLFFBQVEsQ0FBQztBQUM5QixDQUFDO0FBQ0QsT0FBTyxFQUFFLENBQUE7QUFBQyxDQUFDO0lBQ1AsT0FBTyxJQUFJLENBQUMsRUFBRSxDQUFDO0FBQ25CLENBQUM7QUFHTCxNQUFNLENBQUMsSUFBSSxDQUFLLENBQUE7QUFBQyxJQUFJLEdBQUcsRUFBRSxDQUFDLENBQUE7QUFBQyxDQUFDLENBQUE7QUFBQSxDQUFDO0lBQUEsR0FBRyxDQUFBO0lBQUEsRUFBRSxDQUFBO0FBQUEsQ0FBQztBQUFDLENBQUUsSUFBSSxHQUFHLEVBQUUsQ0FBQyxPQUFPLEVBQUUsQ0FBQztBQUUzRCxDQUFDLENBQUE7QUFBQyxDQUFDLENBQUE7QUFBQSxDQUFDO0lBQUEsR0FBRyxDQUFBO0lBQUEsRUFBRSxDQUFBO0FBQUEsQ0FBQztBQUFJLEdBQUcsQ0FBQyJ9,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyCnZhciDtoIDtuqc6IHN0cmluZzsKdmFyIFx1ezEwMkE3fTogc3RyaW5nOwoKaWYgKE1hdGgucmFuZG9tKCkpIHsKICAgIO2ggO26pyA9ICJoZWxsbyI7Cn0KZWxzZSB7CiAgICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7toIDtuqc7CiAgICB9Cn0KCmV4cG9ydCB2YXIgX+2ggO26pyA9IG5ldyBGb28oKS5cdXsxMDJBN30gKyBuZXcgRm9vKCkubWV0aG9kQSgpOwoKX1x1ezEwMkE3fSArPSAiISI7Cg== +{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,IAAI,EAAU,CAAC;AACf,IAAI,SAAiB,CAAC;AAEtB,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAChB,EAAE,GAAG,OAAO,CAAC;AACjB,CAAC;KACI,CAAC;IACF,SAAS,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,GAAG;IAEL;QACI,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IACD,OAAO;QACH,OAAO,IAAI,CAAC,EAAE,CAAC;IACnB,CAAC;CACJ;AAED,MAAM,CAAC,IAAI,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE3D,UAAU,IAAI,GAAG,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyDQp2YXIg7aCA7bqnOw0KdmFyIFx1ezEwMkE3fTsNCmlmIChNYXRoLnJhbmRvbSgpKSB7DQogICAg7aCA7bqnID0gImhlbGxvIjsNCn0NCmVsc2Ugew0KICAgIFx1ezEwMkE3fSA9ICJoYWxsbyI7DQp9DQpjbGFzcyBGb28gew0KICAgIGNvbnN0cnVjdG9yKCkgew0KICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOw0KICAgIH0NCiAgICBtZXRob2RBKCkgew0KICAgICAgICByZXR1cm4gdGhpcy7toIDtuqc7DQogICAgfQ0KfQ0KZXhwb3J0IHZhciBf7aCA7bqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7DQpfXHV7MTAyQTd9ICs9ICIhIjsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWV4dGVuZGVkRXNjYXBlc0ZvckFzdHJhbHNJblZhcnNBbmRDbGFzc2VzLmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5kZWRFc2NhcGVzRm9yQXN0cmFsc0luVmFyc0FuZENsYXNzZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJleHRlbmRlZEVzY2FwZXNGb3JBc3RyYWxzSW5WYXJzQW5kQ2xhc3Nlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQkFBMkI7QUFDM0IsSUFBSSxFQUFVLENBQUM7QUFDZixJQUFJLFNBQWlCLENBQUM7QUFFdEIsSUFBSSxJQUFJLENBQUMsTUFBTSxFQUFFLEVBQUUsQ0FBQztJQUNoQixFQUFFLEdBQUcsT0FBTyxDQUFDO0FBQ2pCLENBQUM7S0FDSSxDQUFDO0lBQ0YsU0FBUyxHQUFHLE9BQU8sQ0FBQztBQUN4QixDQUFDO0FBRUQsTUFBTSxHQUFHO0lBRUw7UUFDSSxJQUFJLENBQUMsU0FBUyxHQUFHLFFBQVEsQ0FBQztJQUM5QixDQUFDO0lBQ0QsT0FBTztRQUNILE9BQU8sSUFBSSxDQUFDLEVBQUUsQ0FBQztJQUNuQixDQUFDO0NBQ0o7QUFFRCxNQUFNLENBQUMsSUFBSSxHQUFHLEdBQUcsSUFBSSxHQUFHLEVBQUUsQ0FBQyxTQUFTLEdBQUcsSUFBSSxHQUFHLEVBQUUsQ0FBQyxPQUFPLEVBQUUsQ0FBQztBQUUzRCxVQUFVLElBQUksR0FBRyxDQUFDIn0=,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyCnZhciDtoIDtuqc6IHN0cmluZzsKdmFyIFx1ezEwMkE3fTogc3RyaW5nOwoKaWYgKE1hdGgucmFuZG9tKCkpIHsKICAgIO2ggO26pyA9ICJoZWxsbyI7Cn0KZWxzZSB7CiAgICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7toIDtuqc7CiAgICB9Cn0KCmV4cG9ydCB2YXIgX+2ggO26pyA9IG5ldyBGb28oKS5cdXsxMDJBN30gKyBuZXcgRm9vKCkubWV0aG9kQSgpOwoKX1x1ezEwMkE3fSArPSAiISI7Cg== //// [astralAsSurrogatePair.js.map] {"version":3,"file":"astralAsSurrogatePair.js","sourceRoot":"","sources":["astralAsSurrogatePair.ts"],"names":[],"mappings":""} diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt index e4ec78b38e7..e9ffa88cad7 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt @@ -16,55 +16,37 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 28) Source(1, 28) + SourceIndex(0) --- ->>>var string; +>>>var 𐊧; 1 > 2 >^^^^ -3 > ^^^^^^ -4 > ^ -5 > ^^^^^^^^^-> +3 > ^^ +4 > ^ +5 > ^^^^^^^^-> 1 > > -2 >var 𐊧: -3 > string -4 > ; +2 >var +3 > 𐊧: string +4 > ; 1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 9) + SourceIndex(0) -3 >Emitted(2, 11) Source(2, 15) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 16) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 15) + SourceIndex(0) +4 >Emitted(2, 8) Source(2, 16) + SourceIndex(0) --- ->>>var u, { 102: A7 }; +>>>var \u{102A7}; 1-> 2 >^^^^ -3 > ^ -4 > ^^ -5 > ^^ -6 > ^^^ -7 > ^^ -8 > ^^ -9 > ^^ -10> ^ -11> ^^-> +3 > ^^^^^^^^^ +4 > ^ +5 > ^^^^^^^-> 1-> > -2 >var \ -3 > u -4 > -5 > { -6 > 102 -7 > -8 > A7 -9 > }: string -10> ; +2 >var +3 > \u{102A7}: string +4 > ; 1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(3, 5) Source(3, 6) + SourceIndex(0) -3 >Emitted(3, 6) Source(3, 7) + SourceIndex(0) -4 >Emitted(3, 8) Source(3, 7) + SourceIndex(0) -5 >Emitted(3, 10) Source(3, 8) + SourceIndex(0) -6 >Emitted(3, 13) Source(3, 11) + SourceIndex(0) -7 >Emitted(3, 15) Source(3, 11) + SourceIndex(0) -8 >Emitted(3, 17) Source(3, 13) + SourceIndex(0) -9 >Emitted(3, 19) Source(3, 22) + SourceIndex(0) -10>Emitted(3, 20) Source(3, 23) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 14) Source(3, 22) + SourceIndex(0) +4 >Emitted(3, 15) Source(3, 23) + SourceIndex(0) --- >>>if (Math.random()) { 1-> @@ -94,17 +76,23 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 7 >Emitted(4, 20) Source(5, 20) + SourceIndex(0) 8 >Emitted(4, 21) Source(5, 21) + SourceIndex(0) --- ->>> "hello"; +>>> 𐊧 = "hello"; 1 >^^^^ -2 > ^^^^^^^ -3 > ^ +2 > ^^ +3 > ^^^ +4 > ^^^^^^^ +5 > ^ 1 > - > 𐊧 = -2 > "hello" -3 > ; -1 >Emitted(5, 5) Source(6, 10) + SourceIndex(0) -2 >Emitted(5, 12) Source(6, 17) + SourceIndex(0) -3 >Emitted(5, 13) Source(6, 18) + SourceIndex(0) + > +2 > 𐊧 +3 > = +4 > "hello" +5 > ; +1 >Emitted(5, 5) Source(6, 5) + SourceIndex(0) +2 >Emitted(5, 7) Source(6, 7) + SourceIndex(0) +3 >Emitted(5, 10) Source(6, 10) + SourceIndex(0) +4 >Emitted(5, 17) Source(6, 17) + SourceIndex(0) +5 >Emitted(5, 18) Source(6, 18) + SourceIndex(0) --- >>>} 1 > @@ -119,75 +107,30 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts >>>else { 1->^^^^^ 2 > ^ -3 > ^-> +3 > ^^^^^^^^^^^^^^^^^^^-> 1-> >else 2 > { 1->Emitted(7, 6) Source(8, 6) + SourceIndex(0) 2 >Emitted(7, 7) Source(8, 7) + SourceIndex(0) --- ->>> u; +>>> \u{102A7} = "hallo"; 1->^^^^ -2 > ^ -3 > ^ +2 > ^^^^^^^^^ +3 > ^^^ +4 > ^^^^^^^ +5 > ^ 1-> - > \ -2 > u -3 > -1->Emitted(8, 5) Source(9, 6) + SourceIndex(0) -2 >Emitted(8, 6) Source(9, 7) + SourceIndex(0) -3 >Emitted(8, 7) Source(9, 7) + SourceIndex(0) ---- ->>> { -1 >^^^^ -2 > ^ -3 > ^^^^^^^^-> -1 > -2 > { -1 >Emitted(9, 5) Source(9, 7) + SourceIndex(0) -2 >Emitted(9, 6) Source(9, 8) + SourceIndex(0) ---- ->>> 102; -1->^^^^^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(10, 9) Source(9, 8) + SourceIndex(0) -2 >Emitted(10, 12) Source(9, 11) + SourceIndex(0) -3 >Emitted(10, 13) Source(9, 11) + SourceIndex(0) ---- ->>> A7; -1 >^^^^^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(11, 9) Source(9, 11) + SourceIndex(0) -2 >Emitted(11, 11) Source(9, 13) + SourceIndex(0) -3 >Emitted(11, 12) Source(9, 13) + SourceIndex(0) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^-> -1 > -2 > } -1 >Emitted(12, 5) Source(9, 13) + SourceIndex(0) -2 >Emitted(12, 6) Source(9, 14) + SourceIndex(0) ---- ->>> "hallo"; -1->^^^^ -2 > ^^^^^^^ -3 > ^ -1-> = -2 > "hallo" -3 > ; -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 12) Source(9, 24) + SourceIndex(0) -3 >Emitted(13, 13) Source(9, 25) + SourceIndex(0) + > +2 > \u{102A7} +3 > = +4 > "hallo" +5 > ; +1->Emitted(8, 5) Source(9, 5) + SourceIndex(0) +2 >Emitted(8, 14) Source(9, 14) + SourceIndex(0) +3 >Emitted(8, 17) Source(9, 17) + SourceIndex(0) +4 >Emitted(8, 24) Source(9, 24) + SourceIndex(0) +5 >Emitted(8, 25) Source(9, 25) + SourceIndex(0) --- >>>} 1 > @@ -196,446 +139,192 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1 > > 2 >} -1 >Emitted(14, 1) Source(10, 1) + SourceIndex(0) -2 >Emitted(14, 2) Source(10, 2) + SourceIndex(0) +1 >Emitted(9, 1) Source(10, 1) + SourceIndex(0) +2 >Emitted(9, 2) Source(10, 2) + SourceIndex(0) --- >>>class Foo { 1-> 2 >^^^^^^ 3 > ^^^ +4 > ^^^^^^^^^^^-> 1-> > > 2 >class 3 > Foo -1->Emitted(15, 1) Source(12, 1) + SourceIndex(0) -2 >Emitted(15, 7) Source(12, 7) + SourceIndex(0) -3 >Emitted(15, 10) Source(12, 10) + SourceIndex(0) +1->Emitted(10, 1) Source(12, 1) + SourceIndex(0) +2 >Emitted(10, 7) Source(12, 7) + SourceIndex(0) +3 >Emitted(10, 10) Source(12, 10) + SourceIndex(0) --- ->>>} -1 >^ -2 > ^-> -1 > { - > \u -1 >Emitted(16, 2) Source(13, 7) + SourceIndex(0) ---- ->>>{ -1-> -2 >^ -3 > ^^^^^^^^-> -1-> -2 >{ -1->Emitted(17, 1) Source(13, 7) + SourceIndex(0) -2 >Emitted(17, 2) Source(13, 8) + SourceIndex(0) ---- ->>> 102; +>>> constructor() { 1->^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(18, 5) Source(13, 8) + SourceIndex(0) -2 >Emitted(18, 8) Source(13, 11) + SourceIndex(0) -3 >Emitted(18, 9) Source(13, 11) + SourceIndex(0) ---- ->>> A7; -1 >^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(19, 5) Source(13, 11) + SourceIndex(0) -2 >Emitted(19, 7) Source(13, 13) + SourceIndex(0) -3 >Emitted(19, 8) Source(13, 13) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^-> -1 > -2 >} -1 >Emitted(20, 1) Source(13, 13) + SourceIndex(0) -2 >Emitted(20, 2) Source(13, 14) + SourceIndex(0) ---- ->>>string; -1-> -2 >^^^^^^ -3 > ^ -4 > ^^^^^^^^-> -1->: -2 >string -3 > ; -1->Emitted(21, 1) Source(13, 16) + SourceIndex(0) -2 >Emitted(21, 7) Source(13, 22) + SourceIndex(0) -3 >Emitted(21, 8) Source(13, 23) + SourceIndex(0) ---- ->>>constructor(); -1-> -2 >^^^^^^^^^^^ -3 > ^^ -4 > ^ -1-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> { + > \u{102A7}: string; > -2 >constructor -3 > () -4 > -1->Emitted(22, 1) Source(14, 5) + SourceIndex(0) -2 >Emitted(22, 12) Source(14, 16) + SourceIndex(0) -3 >Emitted(22, 14) Source(14, 18) + SourceIndex(0) -4 >Emitted(22, 15) Source(14, 18) + SourceIndex(0) +1->Emitted(11, 5) Source(14, 5) + SourceIndex(0) --- ->>>{ -1 > -2 >^ -3 > ^^^^^^^^^^-> -1 > -2 >{ -1 >Emitted(23, 1) Source(14, 19) + SourceIndex(0) -2 >Emitted(23, 2) Source(14, 20) + SourceIndex(0) ---- ->>> this.; -1->^^^^ -2 > ^^^^ -3 > ^ -4 > ^ -1-> - > -2 > this -3 > . -4 > -1->Emitted(24, 5) Source(15, 9) + SourceIndex(0) -2 >Emitted(24, 9) Source(15, 13) + SourceIndex(0) -3 >Emitted(24, 10) Source(15, 14) + SourceIndex(0) -4 >Emitted(24, 11) Source(15, 14) + SourceIndex(0) ---- ->>> u; -1 >^^^^ -2 > ^ -3 > ^ -1 >\ -2 > u -3 > -1 >Emitted(25, 5) Source(15, 15) + SourceIndex(0) -2 >Emitted(25, 6) Source(15, 16) + SourceIndex(0) -3 >Emitted(25, 7) Source(15, 16) + SourceIndex(0) ---- ->>> { -1 >^^^^ -2 > ^ -3 > ^^^^^^^^-> -1 > -2 > { -1 >Emitted(26, 5) Source(15, 16) + SourceIndex(0) -2 >Emitted(26, 6) Source(15, 17) + SourceIndex(0) ---- ->>> 102; +>>> this.\u{102A7} = " world"; 1->^^^^^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(27, 9) Source(15, 17) + SourceIndex(0) -2 >Emitted(27, 12) Source(15, 20) + SourceIndex(0) -3 >Emitted(27, 13) Source(15, 20) + SourceIndex(0) ---- ->>> A7; -1 >^^^^^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(28, 9) Source(15, 20) + SourceIndex(0) -2 >Emitted(28, 11) Source(15, 22) + SourceIndex(0) -3 >Emitted(28, 12) Source(15, 22) + SourceIndex(0) +2 > ^^^^ +3 > ^ +4 > ^^^^^^^^^ +5 > ^^^ +6 > ^^^^^^^^ +7 > ^ +1->constructor() { + > +2 > this +3 > . +4 > \u{102A7} +5 > = +6 > " world" +7 > ; +1->Emitted(12, 9) Source(15, 9) + SourceIndex(0) +2 >Emitted(12, 13) Source(15, 13) + SourceIndex(0) +3 >Emitted(12, 14) Source(15, 14) + SourceIndex(0) +4 >Emitted(12, 23) Source(15, 23) + SourceIndex(0) +5 >Emitted(12, 26) Source(15, 26) + SourceIndex(0) +6 >Emitted(12, 34) Source(15, 34) + SourceIndex(0) +7 >Emitted(12, 35) Source(15, 35) + SourceIndex(0) --- >>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> -1 > -2 > } -1 >Emitted(29, 5) Source(15, 22) + SourceIndex(0) -2 >Emitted(29, 6) Source(15, 23) + SourceIndex(0) ---- ->>> " world"; -1->^^^^ -2 > ^^^^^^^^ -3 > ^ -1-> = -2 > " world" -3 > ; -1->Emitted(30, 5) Source(15, 26) + SourceIndex(0) -2 >Emitted(30, 13) Source(15, 34) + SourceIndex(0) -3 >Emitted(30, 14) Source(15, 35) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^-> +3 > ^^^^^^^^^^^-> 1 > > -2 >} -1 >Emitted(31, 1) Source(16, 5) + SourceIndex(0) -2 >Emitted(31, 2) Source(16, 6) + SourceIndex(0) +2 > } +1 >Emitted(13, 5) Source(16, 5) + SourceIndex(0) +2 >Emitted(13, 6) Source(16, 6) + SourceIndex(0) --- ->>>methodA(); -1-> -2 >^^^^^^^ -3 > ^^ -4 > ^ -1-> - > -2 >methodA -3 > () -4 > -1->Emitted(32, 1) Source(17, 5) + SourceIndex(0) -2 >Emitted(32, 8) Source(17, 12) + SourceIndex(0) -3 >Emitted(32, 10) Source(17, 14) + SourceIndex(0) -4 >Emitted(32, 11) Source(17, 14) + SourceIndex(0) ---- ->>>{ -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^-> -1 > -2 >{ -1 >Emitted(33, 1) Source(17, 15) + SourceIndex(0) -2 >Emitted(33, 2) Source(17, 16) + SourceIndex(0) ---- ->>> return this.𐊧; +>>> methodA() { 1->^^^^ 2 > ^^^^^^^ -3 > ^^^^ -4 > ^ -5 > ^^ -6 > ^ +3 > ^^^^^^^^^^^^^-> 1-> - > -2 > return -3 > this -4 > . -5 > 𐊧 -6 > ; -1->Emitted(34, 5) Source(18, 9) + SourceIndex(0) -2 >Emitted(34, 12) Source(18, 16) + SourceIndex(0) -3 >Emitted(34, 16) Source(18, 20) + SourceIndex(0) -4 >Emitted(34, 17) Source(18, 21) + SourceIndex(0) -5 >Emitted(34, 19) Source(18, 23) + SourceIndex(0) -6 >Emitted(34, 20) Source(18, 24) + SourceIndex(0) + > +2 > methodA +1->Emitted(14, 5) Source(17, 5) + SourceIndex(0) +2 >Emitted(14, 12) Source(17, 12) + SourceIndex(0) --- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^-> +>>> return this.𐊧; +1->^^^^^^^^ +2 > ^^^^^^^ +3 > ^^^^ +4 > ^ +5 > ^^ +6 > ^ +1->() { + > +2 > return +3 > this +4 > . +5 > 𐊧 +6 > ; +1->Emitted(15, 9) Source(18, 9) + SourceIndex(0) +2 >Emitted(15, 16) Source(18, 16) + SourceIndex(0) +3 >Emitted(15, 20) Source(18, 20) + SourceIndex(0) +4 >Emitted(15, 21) Source(18, 21) + SourceIndex(0) +5 >Emitted(15, 23) Source(18, 23) + SourceIndex(0) +6 >Emitted(15, 24) Source(18, 24) + SourceIndex(0) +--- +>>> } +1 >^^^^ +2 > ^ 1 > > -2 >} -1 >Emitted(35, 1) Source(19, 5) + SourceIndex(0) -2 >Emitted(35, 2) Source(19, 6) + SourceIndex(0) +2 > } +1 >Emitted(16, 5) Source(19, 5) + SourceIndex(0) +2 >Emitted(16, 6) Source(19, 6) + SourceIndex(0) --- ->>>export var _; +>>>} +1 >^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >} +1 >Emitted(17, 2) Source(20, 2) + SourceIndex(0) +--- +>>>export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); 1-> 2 >^^^^^^ 3 > ^ 4 > ^^^^ -5 > ^ -6 > ^ +5 > ^^^ +6 > ^^^ +7 > ^^^^ +8 > ^^^ +9 > ^^ +10> ^ +11> ^^^^^^^^^ +12> ^^^ +13> ^^^^ +14> ^^^ +15> ^^ +16> ^ +17> ^^^^^^^ +18> ^^ +19> ^ 1-> - >} > > 2 >export 3 > 4 > var -5 > _𐊧 = -6 > -1->Emitted(36, 1) Source(22, 1) + SourceIndex(0) -2 >Emitted(36, 7) Source(22, 7) + SourceIndex(0) -3 >Emitted(36, 8) Source(22, 8) + SourceIndex(0) -4 >Emitted(36, 12) Source(22, 12) + SourceIndex(0) -5 >Emitted(36, 13) Source(22, 17) + SourceIndex(0) -6 >Emitted(36, 14) Source(22, 17) + SourceIndex(0) +5 > _𐊧 +6 > = +7 > new +8 > Foo +9 > () +10> . +11> \u{102A7} +12> + +13> new +14> Foo +15> () +16> . +17> methodA +18> () +19> ; +1->Emitted(18, 1) Source(22, 1) + SourceIndex(0) +2 >Emitted(18, 7) Source(22, 7) + SourceIndex(0) +3 >Emitted(18, 8) Source(22, 8) + SourceIndex(0) +4 >Emitted(18, 12) Source(22, 12) + SourceIndex(0) +5 >Emitted(18, 15) Source(22, 15) + SourceIndex(0) +6 >Emitted(18, 18) Source(22, 18) + SourceIndex(0) +7 >Emitted(18, 22) Source(22, 22) + SourceIndex(0) +8 >Emitted(18, 25) Source(22, 25) + SourceIndex(0) +9 >Emitted(18, 27) Source(22, 27) + SourceIndex(0) +10>Emitted(18, 28) Source(22, 28) + SourceIndex(0) +11>Emitted(18, 37) Source(22, 37) + SourceIndex(0) +12>Emitted(18, 40) Source(22, 40) + SourceIndex(0) +13>Emitted(18, 44) Source(22, 44) + SourceIndex(0) +14>Emitted(18, 47) Source(22, 47) + SourceIndex(0) +15>Emitted(18, 49) Source(22, 49) + SourceIndex(0) +16>Emitted(18, 50) Source(22, 50) + SourceIndex(0) +17>Emitted(18, 57) Source(22, 57) + SourceIndex(0) +18>Emitted(18, 59) Source(22, 59) + SourceIndex(0) +19>Emitted(18, 60) Source(22, 60) + SourceIndex(0) --- ->>>new Foo().; +>>>_\u{102A7} += "!"; 1 > -2 >^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^ -1 > -2 >new -3 > Foo -4 > () -5 > . -6 > -1 >Emitted(37, 1) Source(22, 18) + SourceIndex(0) -2 >Emitted(37, 5) Source(22, 22) + SourceIndex(0) -3 >Emitted(37, 8) Source(22, 25) + SourceIndex(0) -4 >Emitted(37, 10) Source(22, 27) + SourceIndex(0) -5 >Emitted(37, 11) Source(22, 28) + SourceIndex(0) -6 >Emitted(37, 12) Source(22, 28) + SourceIndex(0) ---- ->>>u; -1 > -2 >^ -3 > ^ -1 >\ -2 >u -3 > -1 >Emitted(38, 1) Source(22, 29) + SourceIndex(0) -2 >Emitted(38, 2) Source(22, 30) + SourceIndex(0) -3 >Emitted(38, 3) Source(22, 30) + SourceIndex(0) ---- ->>>{ -1 > -2 >^ -3 > ^^^^^^^^-> -1 > -2 >{ -1 >Emitted(39, 1) Source(22, 30) + SourceIndex(0) -2 >Emitted(39, 2) Source(22, 31) + SourceIndex(0) ---- ->>> 102; -1->^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(40, 5) Source(22, 31) + SourceIndex(0) -2 >Emitted(40, 8) Source(22, 34) + SourceIndex(0) -3 >Emitted(40, 9) Source(22, 34) + SourceIndex(0) ---- ->>> A7; -1 >^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(41, 5) Source(22, 34) + SourceIndex(0) -2 >Emitted(41, 7) Source(22, 36) + SourceIndex(0) -3 >Emitted(41, 8) Source(22, 36) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -1 >Emitted(42, 1) Source(22, 36) + SourceIndex(0) -2 >Emitted(42, 2) Source(22, 37) + SourceIndex(0) ---- ->>>+new Foo().methodA(); -1-> -2 >^ -3 > ^^^^ -4 > ^^^ -5 > ^^ -6 > ^ -7 > ^^^^^^^ -8 > ^^ -9 > ^ -1-> -2 >+ -3 > new -4 > Foo -5 > () -6 > . -7 > methodA -8 > () -9 > ; -1->Emitted(43, 1) Source(22, 38) + SourceIndex(0) -2 >Emitted(43, 2) Source(22, 40) + SourceIndex(0) -3 >Emitted(43, 6) Source(22, 44) + SourceIndex(0) -4 >Emitted(43, 9) Source(22, 47) + SourceIndex(0) -5 >Emitted(43, 11) Source(22, 49) + SourceIndex(0) -6 >Emitted(43, 12) Source(22, 50) + SourceIndex(0) -7 >Emitted(43, 19) Source(22, 57) + SourceIndex(0) -8 >Emitted(43, 21) Source(22, 59) + SourceIndex(0) -9 >Emitted(43, 22) Source(22, 60) + SourceIndex(0) ---- ->>>_; -1 > -2 >^ -3 > ^ -4 > ^-> +2 >^^^^^^^^^^ +3 > ^^^^ +4 > ^^^ +5 > ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > > -2 >_ -3 > -1 >Emitted(44, 1) Source(24, 1) + SourceIndex(0) -2 >Emitted(44, 2) Source(24, 2) + SourceIndex(0) -3 >Emitted(44, 3) Source(24, 2) + SourceIndex(0) ---- ->>>u; -1-> -2 >^ -3 > ^ -1->\ -2 >u -3 > -1->Emitted(45, 1) Source(24, 3) + SourceIndex(0) -2 >Emitted(45, 2) Source(24, 4) + SourceIndex(0) -3 >Emitted(45, 3) Source(24, 4) + SourceIndex(0) ---- ->>>{ -1 > -2 >^ -3 > ^^^^^^^^-> -1 > -2 >{ -1 >Emitted(46, 1) Source(24, 4) + SourceIndex(0) -2 >Emitted(46, 2) Source(24, 5) + SourceIndex(0) ---- ->>> 102; -1->^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(47, 5) Source(24, 5) + SourceIndex(0) -2 >Emitted(47, 8) Source(24, 8) + SourceIndex(0) -3 >Emitted(47, 9) Source(24, 8) + SourceIndex(0) ---- ->>> A7; -1 >^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(48, 5) Source(24, 8) + SourceIndex(0) -2 >Emitted(48, 7) Source(24, 10) + SourceIndex(0) -3 >Emitted(48, 8) Source(24, 10) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^-> -1 > -2 >} -1 >Emitted(49, 1) Source(24, 10) + SourceIndex(0) -2 >Emitted(49, 2) Source(24, 11) + SourceIndex(0) ---- ->>>"!"; -1-> -2 >^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> += -2 >"!" -3 > ; -1->Emitted(50, 1) Source(24, 15) + SourceIndex(0) -2 >Emitted(50, 4) Source(24, 18) + SourceIndex(0) -3 >Emitted(50, 5) Source(24, 19) + SourceIndex(0) +2 >_\u{102A7} +3 > += +4 > "!" +5 > ; +1 >Emitted(19, 1) Source(24, 1) + SourceIndex(0) +2 >Emitted(19, 11) Source(24, 11) + SourceIndex(0) +3 >Emitted(19, 15) Source(24, 15) + SourceIndex(0) +4 >Emitted(19, 18) Source(24, 18) + SourceIndex(0) +5 >Emitted(19, 19) Source(24, 19) + SourceIndex(0) --- >>>//# sourceMappingURL=extendedEscapesForAstralsInVarsAndClasses.js.map=================================================================== JsFile: astralAsSurrogatePair.js diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols index 2175e1b98cd..06cba0309d2 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols @@ -3,11 +3,10 @@ === extendedEscapesForAstralsInVarsAndClasses.ts === // U+102A7 CARIAN LETTER A2 var 𐊧: string; ->string : Symbol(string, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 1, 7)) +>𐊧 : Symbol(𐊧, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 1, 3), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 3)) var \u{102A7}: string; ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) +>\u{102A7} : Symbol(𐊧, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 1, 3), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 3)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) @@ -15,47 +14,51 @@ if (Math.random()) { >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) 𐊧 = "hello"; +>𐊧 : Symbol(𐊧, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 1, 3), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 3)) } else { \u{102A7} = "hallo"; ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) +>\u{102A7} : Symbol(𐊧, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 1, 3), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 3)) } class Foo { >Foo : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) \u{102A7}: string; ->u : Symbol(Foo.u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 12, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) ->string : Symbol(string, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 1, 7)) +>\u{102A7} : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) constructor() { this.\u{102A7} = " world"; ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) +>this.\u{102A7} : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) +>this : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) +>\u{102A7} : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) } methodA() { +>methodA : Symbol(Foo.methodA, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 15, 5)) + return this.𐊧; +>this.𐊧 : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) +>this : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) +>𐊧 : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) } } export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); ->_ : Symbol(_, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) +>_𐊧 : Symbol(_𐊧, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) +>new Foo().\u{102A7} : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) >Foo : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) +>\u{102A7} : Symbol(Foo[\u{102A7}], Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 11, 11)) +>new Foo().methodA : Symbol(Foo.methodA, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 15, 5)) >Foo : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) +>methodA : Symbol(Foo.methodA, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 15, 5)) _\u{102A7} += "!"; ->_ : Symbol(_, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) +>_\u{102A7} : Symbol(_𐊧, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) === astralAsSurrogatePair.ts === import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; ->_ : Symbol(_, Decl(astralAsSurrogatePair.ts, 0, 8)) ->as : Symbol(as, Decl(astralAsSurrogatePair.ts, 0, 12)) +>_𐊧 : Symbol((Missing), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) +> : Symbol((Missing), Decl(astralAsSurrogatePair.ts, 0, 8)) >uD800 : Symbol(uD800, Decl(astralAsSurrogatePair.ts, 0, 17)) >uDEA7 : Symbol(uDEA7, Decl(astralAsSurrogatePair.ts, 0, 23)) diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types index 25ad36211f7..cc561770d80 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types @@ -3,14 +3,12 @@ === extendedEscapesForAstralsInVarsAndClasses.ts === // U+102A7 CARIAN LETTER A2 var 𐊧: string; ->string : any -> : ^^^ +>𐊧 : string +> : ^^^^^^ var \u{102A7}: string; ->u : any -> : ^^^ ->A7 : string -> : ^^^^^^ +>\u{102A7} : string +> : ^^^^^^ if (Math.random()) { >Math.random() : number @@ -23,17 +21,19 @@ if (Math.random()) { > : ^^^^^^ 𐊧 = "hello"; +>𐊧 = "hello" : "hello" +> : ^^^^^^^ +>𐊧 : string +> : ^^^^^^ >"hello" : "hello" > : ^^^^^^^ } else { \u{102A7} = "hallo"; ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ +>\u{102A7} = "hallo" : "hallo" +> : ^^^^^^^ +>\u{102A7} : string +> : ^^^^^^ >"hallo" : "hallo" > : ^^^^^^^ } @@ -43,101 +43,74 @@ class Foo { > : ^^^ \u{102A7}: string; ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ ->string : any -> : ^^^ +>\u{102A7} : string +> : ^^^^^^ constructor() { ->constructor() : any -> : ^^^ ->constructor : any -> : ^^^ - this.\u{102A7} = " world"; ->this. : any -> : ^^^ ->this : undefined -> : ^^^^^^^^^ -> : any -> : ^^^ ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ +>this.\u{102A7} = " world" : " world" +> : ^^^^^^^^ +>this.\u{102A7} : string +> : ^^^^^^ +>this : this +> : ^^^^ +>\u{102A7} : string +> : ^^^^^^ >" world" : " world" > : ^^^^^^^^ } methodA() { ->methodA() : any -> : ^^^ ->methodA : any -> : ^^^ +>methodA : () => string +> : ^^^^^^^^^^^^ return this.𐊧; ->this.𐊧 : any -> : ^^^ ->this : undefined -> : ^^^^^^^^^ ->𐊧 : any -> : ^^^ +>this.𐊧 : string +> : ^^^^^^ +>this : this +> : ^^^^ +>𐊧 : string +> : ^^^^^^ } } export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); ->_ : any -> : ^^^ ->new Foo(). : any -> : ^^^ +>_𐊧 : string +> : ^^^^^^ +>new Foo().\u{102A7} + new Foo().methodA() : string +> : ^^^^^^ +>new Foo().\u{102A7} : string +> : ^^^^^^ >new Foo() : Foo > : ^^^ >Foo : typeof Foo > : ^^^^^^^^^^ -> : any -> : ^^^ ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ ->+ new Foo().methodA() : number -> : ^^^^^^ ->new Foo().methodA() : any -> : ^^^ ->new Foo().methodA : any -> : ^^^ +>\u{102A7} : string +> : ^^^^^^ +>new Foo().methodA() : string +> : ^^^^^^ +>new Foo().methodA : () => string +> : ^^^^^^^^^^^^ >new Foo() : Foo > : ^^^ >Foo : typeof Foo > : ^^^^^^^^^^ ->methodA : any -> : ^^^ +>methodA : () => string +> : ^^^^^^^^^^^^ _\u{102A7} += "!"; ->_ : any -> : ^^^ ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ +>_\u{102A7} += "!" : string +> : ^^^^^^ +>_\u{102A7} : string +> : ^^^^^^ >"!" : "!" > : ^^^ === astralAsSurrogatePair.ts === import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; ->_ : any -> : ^^^ ->as : any -> : ^^^ +>_𐊧 : string +> : ^^^^^^ +> : string +> : ^^^^^^ >uD800 : any > : ^^^ >uDEA7 : any