@tsrx/content-mapper 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{mapper-SyX-87Od.js → mapper-CiYVAopk.js} +433 -6
- package/dist/mapper-CiYVAopk.js.map +1 -0
- package/dist/mapper.js +1 -1
- package/dist/server.js +1 -1
- package/package.json +7 -7
- package/src/diagnostic-directives.js +10 -2
- package/src/span-mappings.js +34 -6
- package/dist/mapper-SyX-87Od.js.map +0 -1
|
@@ -2447,6 +2447,10 @@ const DIAGNOSTIC_CODES = {
|
|
|
2447
2447
|
* it renders nothing.
|
|
2448
2448
|
*/
|
|
2449
2449
|
CODE_BLOCK_EXPRESSION_ONLY: "TSRX2035",
|
|
2450
|
+
/** A `break` that would leave an `@try`, `@pending`, `@catch` or `@empty` body, or a nested `@{ … }` block. */
|
|
2451
|
+
DIRECTIVE_BODY_BREAK: "TSRX2036",
|
|
2452
|
+
/** A `continue` that would leave an `@try`, `@pending`, `@catch`, `@empty` or `@switch` case body, or a nested `@{ … }` block. */
|
|
2453
|
+
DIRECTIVE_BODY_CONTINUE: "TSRX2037",
|
|
2450
2454
|
/** `<style apply>` carries no expression value. */
|
|
2451
2455
|
STYLE_APPLY_VALUE: "TSRX3001",
|
|
2452
2456
|
/** An `apply` entry is not an identifier, member, or array of those, or does not resolve to a style block. */
|
|
@@ -2475,6 +2479,8 @@ const DIAGNOSTIC_CODES = {
|
|
|
2475
2479
|
CSS_SYNTAX: "TSRX3013",
|
|
2476
2480
|
/** A `<style>` block in a child expression container (`{<style>…</style>}`), which renders its class map. */
|
|
2477
2481
|
STYLE_IN_EXPRESSION_CONTAINER: "TSRX3014",
|
|
2482
|
+
/** An `&` with no rule around it in the output, which would match the page's root element. */
|
|
2483
|
+
CSS_NESTING_SELECTOR_PLACEMENT: "TSRX3015",
|
|
2478
2484
|
/** A recognized `import.meta.env.platform.*` flag is used without a selected platform. */
|
|
2479
2485
|
PLATFORM_REQUIRED: "TSRX4001",
|
|
2480
2486
|
/** A name that starts with the prefix the compiler reserves for its own identifiers. */
|
|
@@ -2507,6 +2513,399 @@ const MAPPER_CODES = {
|
|
|
2507
2513
|
/** The project's TSRX configuration is invalid. */
|
|
2508
2514
|
INVALID_CONFIG: /* @__PURE__ */ mapper_code(1003)
|
|
2509
2515
|
};
|
|
2516
|
+
/**
|
|
2517
|
+
* An error TSRX reports: its code, TSRX's own or TypeScript's for a mistake
|
|
2518
|
+
* TypeScript also reports, and its message.
|
|
2519
|
+
* @typedef {{ code: string, message: string }} Diagnostic
|
|
2520
|
+
*/
|
|
2521
|
+
/**
|
|
2522
|
+
* An error whose message takes values, such as a name from the source. Called
|
|
2523
|
+
* with them, it gives the {@link Diagnostic}; its `code` is the code of every
|
|
2524
|
+
* message it gives.
|
|
2525
|
+
* @typedef {((...values: string[]) => Diagnostic) & { code: string }} DiagnosticWithValues
|
|
2526
|
+
*/
|
|
2527
|
+
/**
|
|
2528
|
+
* @param {string} code
|
|
2529
|
+
* @param {(...values: string[]) => string} message
|
|
2530
|
+
* @returns {DiagnosticWithValues}
|
|
2531
|
+
*/
|
|
2532
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2533
|
+
function with_values(code, message) {
|
|
2534
|
+
return Object.assign((...values) => ({
|
|
2535
|
+
code,
|
|
2536
|
+
message: message(...values)
|
|
2537
|
+
}), { code });
|
|
2538
|
+
}
|
|
2539
|
+
/**
|
|
2540
|
+
* The errors TSRX reports for mistakes TypeScript also reports, each with
|
|
2541
|
+
* TypeScript's code for the same mistake. Most have TypeScript's wording too;
|
|
2542
|
+
* the ones in acorn's or acorn-typescript's wording are the upstream errors
|
|
2543
|
+
* TSRX raises itself where it reads the code in their place. A test checks the
|
|
2544
|
+
* wording of each against TypeScript's.
|
|
2545
|
+
*/
|
|
2546
|
+
const TS_ERRORS = {
|
|
2547
|
+
/** `token` is the token expected, such as `}`. */
|
|
2548
|
+
TOKEN_EXPECTED: /* @__PURE__ */ with_values("TS1005", (token) => `'${token}' expected.`),
|
|
2549
|
+
IDENTIFIER_EXPECTED: {
|
|
2550
|
+
code: "TS1003",
|
|
2551
|
+
message: "Identifier expected."
|
|
2552
|
+
},
|
|
2553
|
+
RESERVED_WORD_AS_IDENTIFIER: /* @__PURE__ */ with_values("TS1359", (word) => `Identifier expected. '${word}' is a reserved word that cannot be used here.`),
|
|
2554
|
+
IDENTIFIER_OR_STRING_EXPECTED: {
|
|
2555
|
+
code: "TS1478",
|
|
2556
|
+
message: "Identifier or string literal expected."
|
|
2557
|
+
},
|
|
2558
|
+
CATCH_OR_FINALLY_EXPECTED: {
|
|
2559
|
+
code: "TS1472",
|
|
2560
|
+
message: "'catch' or 'finally' expected."
|
|
2561
|
+
},
|
|
2562
|
+
/** `word` is the word. */
|
|
2563
|
+
STRICT_MODE_RESERVED_WORD: /* @__PURE__ */ with_values("TS1214", (word) => `Identifier expected. '${word}' is a reserved word in strict mode. Modules are automatically in strict mode.`),
|
|
2564
|
+
/** `word` is the word. */
|
|
2565
|
+
STRICT_MODE_RESERVED_WORD_IN_CLASS: /* @__PURE__ */ with_values("TS1213", (word) => `Identifier expected. '${word}' is a reserved word in strict mode. Class definitions are automatically in strict mode.`),
|
|
2566
|
+
LET_DECLARATION_NAME: {
|
|
2567
|
+
code: "TS2480",
|
|
2568
|
+
message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations."
|
|
2569
|
+
},
|
|
2570
|
+
DECLARATION_EXPECTED: {
|
|
2571
|
+
code: "TS1146",
|
|
2572
|
+
message: "Declaration expected."
|
|
2573
|
+
},
|
|
2574
|
+
UNEXPECTED_KEYWORD_OR_IDENTIFIER: {
|
|
2575
|
+
code: "TS1434",
|
|
2576
|
+
message: "Unexpected keyword or identifier."
|
|
2577
|
+
},
|
|
2578
|
+
/** `suggestion` is the keyword, or the keyword and the rest of the name. */
|
|
2579
|
+
UNKNOWN_KEYWORD_OR_IDENTIFIER: /* @__PURE__ */ with_values("TS1435", (suggestion) => `Unknown keyword or identifier. Did you mean '${suggestion}'?`),
|
|
2580
|
+
/** `kind` is `let`, `const`, `using` or `await using`. */
|
|
2581
|
+
BLOCK_SCOPED_DECLARATION_OUTSIDE_BLOCK: /* @__PURE__ */ with_values("TS1156", (kind) => `'${kind}' declarations can only be declared inside a block.`),
|
|
2582
|
+
LABEL_NOT_ALLOWED: {
|
|
2583
|
+
code: "TS1344",
|
|
2584
|
+
message: "'A label is not allowed here."
|
|
2585
|
+
},
|
|
2586
|
+
VARIABLE_DECLARATION_NOT_ALLOWED: {
|
|
2587
|
+
code: "TS1440",
|
|
2588
|
+
message: "Variable declaration not allowed at this location."
|
|
2589
|
+
},
|
|
2590
|
+
EXPRESSION_EXPECTED: {
|
|
2591
|
+
code: "TS1109",
|
|
2592
|
+
message: "Expression expected."
|
|
2593
|
+
},
|
|
2594
|
+
OPTIONAL_CHAIN_TAGGED_TEMPLATE: {
|
|
2595
|
+
code: "TS1358",
|
|
2596
|
+
message: "Tagged template expressions are not permitted in an optional chain."
|
|
2597
|
+
},
|
|
2598
|
+
DECLARATION_OR_STATEMENT_EXPECTED: {
|
|
2599
|
+
code: "TS1128",
|
|
2600
|
+
message: "Declaration or statement expected."
|
|
2601
|
+
},
|
|
2602
|
+
LINE_BREAK_NOT_PERMITTED: {
|
|
2603
|
+
code: "TS1142",
|
|
2604
|
+
message: "Line break not permitted here."
|
|
2605
|
+
},
|
|
2606
|
+
KEYWORD_ESCAPE: {
|
|
2607
|
+
code: "TS1260",
|
|
2608
|
+
message: "Keywords cannot contain escape characters."
|
|
2609
|
+
},
|
|
2610
|
+
JSX_NAME_UNICODE_ESCAPE: {
|
|
2611
|
+
code: "TS17021",
|
|
2612
|
+
message: "Unicode escape sequence cannot appear here."
|
|
2613
|
+
},
|
|
2614
|
+
PRIVATE_IDENTIFIER_OUTSIDE_CLASS: {
|
|
2615
|
+
code: "TS18016",
|
|
2616
|
+
message: "Private identifiers are not allowed outside class bodies."
|
|
2617
|
+
},
|
|
2618
|
+
MODIFIER_ALREADY_SEEN: /* @__PURE__ */ with_values("TS1030", (modifier) => `'${modifier}' modifier already seen.`),
|
|
2619
|
+
MODIFIER_MUST_PRECEDE: /* @__PURE__ */ with_values("TS1029", (modifier, other) => `'${modifier}' modifier must precede '${other}' modifier.`),
|
|
2620
|
+
MODIFIER_CANNOT_BE_USED_WITH: /* @__PURE__ */ with_values("TS1243", (modifier, other) => `'${modifier}' modifier cannot be used with '${other}' modifier.`),
|
|
2621
|
+
MODIFIER_IN_AMBIENT_CONTEXT: /* @__PURE__ */ with_values("TS1040", (modifier) => `'${modifier}' modifier cannot be used in an ambient context.`),
|
|
2622
|
+
MODIFIER_CANNOT_BE_USED_HERE: /* @__PURE__ */ with_values("TS1042", (modifier) => `'${modifier}' modifier cannot be used here.`),
|
|
2623
|
+
MODIFIER_ON_MODULE_ELEMENT: /* @__PURE__ */ with_values("TS1044", (modifier) => `'${modifier}' modifier cannot appear on a module or namespace element.`),
|
|
2624
|
+
MODIFIER_ON_USING: /* @__PURE__ */ with_values("TS1491", (modifier) => `'${modifier}' modifier cannot appear on a 'using' declaration.`),
|
|
2625
|
+
MODIFIER_ON_AWAIT_USING: /* @__PURE__ */ with_values("TS1495", (modifier) => `'${modifier}' modifier cannot appear on an 'await using' declaration.`),
|
|
2626
|
+
MODIFIERS_CANNOT_APPEAR_HERE: {
|
|
2627
|
+
code: "TS1184",
|
|
2628
|
+
message: "Modifiers cannot appear here."
|
|
2629
|
+
},
|
|
2630
|
+
MODIFIER_ON_CONSTRUCTOR: /* @__PURE__ */ with_values("TS1089", (modifier) => `'${modifier}' modifier cannot appear on a constructor declaration.`),
|
|
2631
|
+
ACCESSIBILITY_MODIFIER_ALREADY_SEEN: {
|
|
2632
|
+
code: "TS1028",
|
|
2633
|
+
message: "Accessibility modifier already seen."
|
|
2634
|
+
},
|
|
2635
|
+
READONLY_MODIFIER_NOT_ALLOWED: {
|
|
2636
|
+
code: "TS1024",
|
|
2637
|
+
message: "'readonly' modifier can only appear on a property declaration or index signature."
|
|
2638
|
+
},
|
|
2639
|
+
ACCESSOR_MODIFIER_NOT_ALLOWED: {
|
|
2640
|
+
code: "TS1275",
|
|
2641
|
+
message: "'accessor' modifier can only appear on a property declaration."
|
|
2642
|
+
},
|
|
2643
|
+
ABSTRACT_MODIFIER_NOT_ALLOWED: {
|
|
2644
|
+
code: "TS1242",
|
|
2645
|
+
message: "'abstract' modifier can only appear on a class, method, or property declaration."
|
|
2646
|
+
},
|
|
2647
|
+
DECLARE_MODIFIER_IN_AMBIENT_CONTEXT: {
|
|
2648
|
+
code: "TS1038",
|
|
2649
|
+
message: "A 'declare' modifier cannot be used in an already ambient context."
|
|
2650
|
+
},
|
|
2651
|
+
/** Decorators on a class `static` block. */
|
|
2652
|
+
DECORATORS_NOT_VALID_HERE: {
|
|
2653
|
+
code: "TS1206",
|
|
2654
|
+
message: "Decorators are not valid here."
|
|
2655
|
+
},
|
|
2656
|
+
MODIFIER_ON_IMPORT: /* @__PURE__ */ with_values("TS1079", (modifier) => `A '${modifier}' modifier cannot be used with an import declaration.`),
|
|
2657
|
+
EXPORT_MODIFIER_ON_AUGMENTATION: {
|
|
2658
|
+
code: "TS2668",
|
|
2659
|
+
message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible."
|
|
2660
|
+
},
|
|
2661
|
+
READONLY_TYPE_MODIFIER: {
|
|
2662
|
+
code: "TS1354",
|
|
2663
|
+
message: "'readonly' type modifier is only permitted on array and tuple literal types."
|
|
2664
|
+
},
|
|
2665
|
+
NESTED_IMPORT: {
|
|
2666
|
+
code: "TS1232",
|
|
2667
|
+
message: "An import declaration can only be used at the top level of a namespace or module."
|
|
2668
|
+
},
|
|
2669
|
+
NESTED_EXPORT: {
|
|
2670
|
+
code: "TS1233",
|
|
2671
|
+
message: "An export declaration can only be used at the top level of a namespace or module."
|
|
2672
|
+
},
|
|
2673
|
+
NESTED_EXPORT_ASSIGNMENT: {
|
|
2674
|
+
code: "TS1231",
|
|
2675
|
+
message: "An export assignment must be at the top level of a file or module declaration."
|
|
2676
|
+
},
|
|
2677
|
+
NESTED_DEFAULT_EXPORT: {
|
|
2678
|
+
code: "TS1258",
|
|
2679
|
+
message: "A default export must be at the top level of a file or module declaration."
|
|
2680
|
+
},
|
|
2681
|
+
NESTED_NAMESPACE: {
|
|
2682
|
+
code: "TS1235",
|
|
2683
|
+
message: "A namespace declaration is only allowed at the top level of a namespace or module."
|
|
2684
|
+
},
|
|
2685
|
+
NESTED_AMBIENT_MODULE: {
|
|
2686
|
+
code: "TS1234",
|
|
2687
|
+
message: "An ambient module declaration is only allowed at the top level in a file."
|
|
2688
|
+
},
|
|
2689
|
+
NESTED_GLOBAL_EXPORT: {
|
|
2690
|
+
code: "TS1316",
|
|
2691
|
+
message: "Global module exports may only appear at top level."
|
|
2692
|
+
},
|
|
2693
|
+
JUMP_ACROSS_FUNCTION: {
|
|
2694
|
+
code: "TS1107",
|
|
2695
|
+
message: "Jump target cannot cross function boundary."
|
|
2696
|
+
},
|
|
2697
|
+
BREAK_OUTSIDE_LOOP: {
|
|
2698
|
+
code: "TS1105",
|
|
2699
|
+
message: "A 'break' statement can only be used within an enclosing iteration or switch statement."
|
|
2700
|
+
},
|
|
2701
|
+
CONTINUE_OUTSIDE_LOOP: {
|
|
2702
|
+
code: "TS1104",
|
|
2703
|
+
message: "A 'continue' statement can only be used within an enclosing iteration statement."
|
|
2704
|
+
},
|
|
2705
|
+
BREAK_LABEL_NOT_FOUND: {
|
|
2706
|
+
code: "TS1116",
|
|
2707
|
+
message: "A 'break' statement can only jump to a label of an enclosing statement."
|
|
2708
|
+
},
|
|
2709
|
+
CONTINUE_LABEL_NOT_LOOP: {
|
|
2710
|
+
code: "TS1115",
|
|
2711
|
+
message: "A 'continue' statement can only jump to a label of an enclosing iteration statement."
|
|
2712
|
+
},
|
|
2713
|
+
AWAIT_EXPRESSION_NOT_ALLOWED: {
|
|
2714
|
+
code: "TS1308",
|
|
2715
|
+
message: "'await' expressions are only allowed within async functions and at the top levels of modules."
|
|
2716
|
+
},
|
|
2717
|
+
FOR_AWAIT_NOT_ALLOWED: {
|
|
2718
|
+
code: "TS1103",
|
|
2719
|
+
message: "'for await' loops are only allowed within async functions and at the top levels of modules."
|
|
2720
|
+
},
|
|
2721
|
+
AWAIT_USING_NOT_ALLOWED: {
|
|
2722
|
+
code: "TS2852",
|
|
2723
|
+
message: "'await using' statements are only allowed within async functions and at the top levels of modules."
|
|
2724
|
+
},
|
|
2725
|
+
IMPORT_DEFER_DEFAULT: {
|
|
2726
|
+
code: "TS18058",
|
|
2727
|
+
message: "Default imports are not allowed in a deferred import."
|
|
2728
|
+
},
|
|
2729
|
+
IMPORT_DEFER_NAMED: {
|
|
2730
|
+
code: "TS18059",
|
|
2731
|
+
message: "Named imports are not allowed in a deferred import."
|
|
2732
|
+
},
|
|
2733
|
+
IMPORT_SOURCE_BINDING: {
|
|
2734
|
+
code: "TS18111",
|
|
2735
|
+
message: "A source phase import must specify a local binding."
|
|
2736
|
+
},
|
|
2737
|
+
IMPORT_SOURCE_NAMED: {
|
|
2738
|
+
code: "TS18112",
|
|
2739
|
+
message: "Named and namespace imports are not allowed in a source phase import."
|
|
2740
|
+
},
|
|
2741
|
+
/** `name` is the name after `import.`. */
|
|
2742
|
+
IMPORT_META_PROPERTY_CALL: /* @__PURE__ */ with_values("TS18061", (name) => `'${name}' is not a valid meta-property for keyword 'import'. Did you mean 'meta' or 'defer'?`),
|
|
2743
|
+
STRING_LITERAL_EXPECTED: {
|
|
2744
|
+
code: "TS1141",
|
|
2745
|
+
message: "String literal expected."
|
|
2746
|
+
},
|
|
2747
|
+
VARIABLE_DECLARATION_EXPECTED: {
|
|
2748
|
+
code: "TS1134",
|
|
2749
|
+
message: "Variable declaration expected."
|
|
2750
|
+
},
|
|
2751
|
+
VARIABLE_DECLARATION_LIST_EMPTY: {
|
|
2752
|
+
code: "TS1123",
|
|
2753
|
+
message: "Variable declaration list cannot be empty."
|
|
2754
|
+
},
|
|
2755
|
+
/** `kind` is `const`, `using`, or `await using`. */
|
|
2756
|
+
DECLARATION_NOT_INITIALIZED: /* @__PURE__ */ with_values("TS1155", (kind) => `'${kind}' declarations must be initialized.`),
|
|
2757
|
+
FOR_IN_USING: {
|
|
2758
|
+
code: "TS1493",
|
|
2759
|
+
message: "The left-hand side of a 'for...in' statement cannot be a 'using' declaration."
|
|
2760
|
+
},
|
|
2761
|
+
FOR_IN_AWAIT_USING: {
|
|
2762
|
+
code: "TS1494",
|
|
2763
|
+
message: "The left-hand side of a 'for...in' statement cannot be an 'await using' declaration."
|
|
2764
|
+
},
|
|
2765
|
+
BLOCK_SCOPED_VARIABLE_REDECLARED: /* @__PURE__ */ with_values("TS2451", (name) => `Cannot redeclare block-scoped variable '${name}'.`),
|
|
2766
|
+
OUTER_SCOPED_VARIABLE_INITIALIZED: /* @__PURE__ */ with_values("TS2481", (name, declaration) => `Cannot initialize outer scoped variable '${name}' in the same scope as block scoped declaration '${declaration}'.`),
|
|
2767
|
+
CATCH_PARAMETER_REDECLARED: /* @__PURE__ */ with_values("TS2492", (name) => `Cannot redeclare identifier '${name}' in catch clause.`),
|
|
2768
|
+
ENUM_REDECLARED: {
|
|
2769
|
+
code: "TS2567",
|
|
2770
|
+
message: "Enum declarations can only merge with namespace or other enum declarations."
|
|
2771
|
+
},
|
|
2772
|
+
/** `name` is the name, or a string name in its quotes. */
|
|
2773
|
+
DUPLICATE_IDENTIFIER: /* @__PURE__ */ with_values("TS2300", (name) => `Duplicate identifier '${name}'.`),
|
|
2774
|
+
MULTIPLE_DEFAULT_EXPORTS: {
|
|
2775
|
+
code: "TS2528",
|
|
2776
|
+
message: "A module cannot have multiple default exports."
|
|
2777
|
+
},
|
|
2778
|
+
AMBIENT_IMPLEMENTATION: {
|
|
2779
|
+
code: "TS1183",
|
|
2780
|
+
message: "An implementation cannot be declared in ambient contexts."
|
|
2781
|
+
},
|
|
2782
|
+
IMPORT_ALIAS_IMPORT_TYPE: {
|
|
2783
|
+
code: "TS1392",
|
|
2784
|
+
message: "An import alias cannot use 'import type'"
|
|
2785
|
+
},
|
|
2786
|
+
TYPE_IMPORT_DEFAULT_AND_NAMED: {
|
|
2787
|
+
code: "TS1363",
|
|
2788
|
+
message: "A type-only import can specify a default import or named bindings, but not both."
|
|
2789
|
+
},
|
|
2790
|
+
SIGNATURE_PARAMETER_INITIALIZER: {
|
|
2791
|
+
code: "TS2371",
|
|
2792
|
+
message: "A parameter initializer is only allowed in a function or constructor implementation."
|
|
2793
|
+
},
|
|
2794
|
+
PATTERN_PARAMETER_PROPERTY: {
|
|
2795
|
+
code: "TS1187",
|
|
2796
|
+
message: "A parameter property may not be declared using a binding pattern."
|
|
2797
|
+
},
|
|
2798
|
+
REST_PARAMETER_PROPERTY: {
|
|
2799
|
+
code: "TS1317",
|
|
2800
|
+
message: "A parameter property cannot be declared using a rest parameter."
|
|
2801
|
+
},
|
|
2802
|
+
PARAMETER_PROPERTY_OUTSIDE_CONSTRUCTOR: {
|
|
2803
|
+
code: "TS2369",
|
|
2804
|
+
message: "A parameter property is only allowed in a constructor implementation."
|
|
2805
|
+
},
|
|
2806
|
+
REST_PARAMETER_INITIALIZER: {
|
|
2807
|
+
code: "TS1048",
|
|
2808
|
+
message: "A rest parameter cannot have an initializer."
|
|
2809
|
+
},
|
|
2810
|
+
REST_ELEMENT_INITIALIZER: {
|
|
2811
|
+
code: "TS1186",
|
|
2812
|
+
message: "A rest element cannot have an initializer."
|
|
2813
|
+
},
|
|
2814
|
+
OPTIONAL_REST_PARAMETER: {
|
|
2815
|
+
code: "TS1047",
|
|
2816
|
+
message: "A rest parameter cannot be optional."
|
|
2817
|
+
},
|
|
2818
|
+
OPTIONAL_BINDING_PATTERN_PARAMETER: {
|
|
2819
|
+
code: "TS2463",
|
|
2820
|
+
message: "A binding pattern parameter cannot be optional in an implementation signature."
|
|
2821
|
+
},
|
|
2822
|
+
UNEXPECTED_TOKEN: {
|
|
2823
|
+
code: "TS1012",
|
|
2824
|
+
message: "Unexpected token"
|
|
2825
|
+
},
|
|
2826
|
+
REST_PARAMETER_NOT_LAST: {
|
|
2827
|
+
code: "TS1014",
|
|
2828
|
+
message: "A rest parameter must be last in a parameter list."
|
|
2829
|
+
},
|
|
2830
|
+
REST_ELEMENT_NOT_LAST: {
|
|
2831
|
+
code: "TS2462",
|
|
2832
|
+
message: "A rest element must be last in a destructuring pattern."
|
|
2833
|
+
},
|
|
2834
|
+
REST_ELEMENT_TRAILING_COMMA: {
|
|
2835
|
+
code: "TS1013",
|
|
2836
|
+
message: "Comma is not permitted after the rest element"
|
|
2837
|
+
},
|
|
2838
|
+
ARGUMENT_NAME_CLASH: {
|
|
2839
|
+
code: "TS2300",
|
|
2840
|
+
message: "Argument name clash"
|
|
2841
|
+
},
|
|
2842
|
+
KEYWORD_ESCAPE_SEQUENCE: /* @__PURE__ */ with_values("TS1260", (keyword) => `Escape sequence in keyword ${keyword}`),
|
|
2843
|
+
AWAIT_USING_OUTSIDE_ASYNC: {
|
|
2844
|
+
code: "TS2852",
|
|
2845
|
+
message: "Await using cannot appear outside of async function"
|
|
2846
|
+
},
|
|
2847
|
+
FOR_IN_INITIALIZER: {
|
|
2848
|
+
code: "TS1189",
|
|
2849
|
+
message: "for-in loop variable declaration may not have an initializer"
|
|
2850
|
+
},
|
|
2851
|
+
FOR_OF_INITIALIZER: {
|
|
2852
|
+
code: "TS1190",
|
|
2853
|
+
message: "for-of loop variable declaration may not have an initializer"
|
|
2854
|
+
},
|
|
2855
|
+
MISSING_CATCH_OR_FINALLY: {
|
|
2856
|
+
code: "TS1472",
|
|
2857
|
+
message: "Missing catch or finally clause"
|
|
2858
|
+
},
|
|
2859
|
+
MULTIPLE_DEFAULT_CLAUSES: {
|
|
2860
|
+
code: "TS1113",
|
|
2861
|
+
message: "Multiple default clauses"
|
|
2862
|
+
},
|
|
2863
|
+
USE_STRICT_NON_SIMPLE_PARAMETERS: {
|
|
2864
|
+
code: "TS1347",
|
|
2865
|
+
message: "Illegal 'use strict' directive in function with non-simple parameter list"
|
|
2866
|
+
},
|
|
2867
|
+
JSX_UNESCAPED_CLOSING_BRACE: {
|
|
2868
|
+
code: "TS1381",
|
|
2869
|
+
message: "Unexpected token `}`. Did you mean `}` or `{\"}\"}`?"
|
|
2870
|
+
},
|
|
2871
|
+
JSX_ATTRIBUTE_EMPTY_EXPRESSION: {
|
|
2872
|
+
code: "TS17000",
|
|
2873
|
+
message: "JSX attributes must only be assigned a non-empty expression"
|
|
2874
|
+
},
|
|
2875
|
+
JSX_ATTRIBUTE_VALUE: {
|
|
2876
|
+
code: "TS1145",
|
|
2877
|
+
message: "value should be either an expression or a quoted text"
|
|
2878
|
+
},
|
|
2879
|
+
ONLY_STRING_ATTRIBUTE_VALUE: {
|
|
2880
|
+
code: "TS2858",
|
|
2881
|
+
message: "Only string is supported as an attribute value"
|
|
2882
|
+
},
|
|
2883
|
+
TYPE_IMPORT_ARGUMENT: {
|
|
2884
|
+
code: "TS1141",
|
|
2885
|
+
message: "Argument in a type import must be a string literal."
|
|
2886
|
+
},
|
|
2887
|
+
UNEXPECTED_LEADING_DECORATOR: {
|
|
2888
|
+
code: "TS1206",
|
|
2889
|
+
message: "Leading decorators must be attached to a class declaration."
|
|
2890
|
+
},
|
|
2891
|
+
TYPE_CAST_IN_PARAMETER: {
|
|
2892
|
+
code: "TS1005",
|
|
2893
|
+
message: "Unexpected type cast in parameter position."
|
|
2894
|
+
},
|
|
2895
|
+
UNEXPECTED_TYPE_ANNOTATION: {
|
|
2896
|
+
code: "TS1005",
|
|
2897
|
+
message: "Did not expect a type annotation here."
|
|
2898
|
+
},
|
|
2899
|
+
RESERVED_ARROW_TYPE_PARAMETER: {
|
|
2900
|
+
code: "TS7060",
|
|
2901
|
+
message: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`."
|
|
2902
|
+
},
|
|
2903
|
+
/** A type assertion written `<T>x` in a `.mts` or `.cts` file. */
|
|
2904
|
+
RESERVED_TYPE_ASSERTION: {
|
|
2905
|
+
code: "TS7059",
|
|
2906
|
+
message: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2510
2909
|
|
|
2511
2910
|
//#endregion
|
|
2512
2911
|
//#region src/diagnostic-directives.js
|
|
@@ -2519,6 +2918,7 @@ const MAPPER_CODES = {
|
|
|
2519
2918
|
* error.
|
|
2520
2919
|
*/
|
|
2521
2920
|
const HOLDER_TYPE = /(?:Statement|Declaration|Definition|Signature)$|^(?:StaticBlock|AccessorProperty|JSXElement|JSXFragment|JSXStyleElement)$/;
|
|
2921
|
+
const JSX_NAME_ESCAPE_CODE = TS_ERRORS.JSX_NAME_UNICODE_ESCAPE.code;
|
|
2522
2922
|
/** Keys of a tree node that hold no child nodes, or nodes that aren't its children. */
|
|
2523
2923
|
const NOT_CHILDREN = /* @__PURE__ */ new Set([
|
|
2524
2924
|
"metadata",
|
|
@@ -2570,7 +2970,7 @@ function ignore_directives(errors, source_ast, mappings, original_length, genera
|
|
|
2570
2970
|
if (typeof error.pos !== "number") continue;
|
|
2571
2971
|
const on_tag = reported_on_tag(error);
|
|
2572
2972
|
const position = on_tag ? error.raisedAt - 1 : error.pos;
|
|
2573
|
-
const holder = source_ast ? holder_at(source_ast, position) : null;
|
|
2973
|
+
const holder = source_ast && error.code !== JSX_NAME_ESCAPE_CODE ? holder_at(source_ast, position) : null;
|
|
2574
2974
|
const start = holder ? holder.start : error.pos;
|
|
2575
2975
|
const end = holder ? holder.end : typeof error.end === "number" && error.end > error.pos ? error.end : error.pos + 1;
|
|
2576
2976
|
const own_code = on_tag && !holder;
|
|
@@ -3151,6 +3551,14 @@ function features_from_mapping_data(data) {
|
|
|
3151
3551
|
* the span exactly show the authored name.
|
|
3152
3552
|
* - Anything else → `Atom`.
|
|
3153
3553
|
*
|
|
3554
|
+
* Mappings over the same ranges in both files are one candidate. A container
|
|
3555
|
+
* mapped for diagnostics only can cover exactly the text of the token inside
|
|
3556
|
+
* it (`item` in a Vue `{item.label}`, a Solid `key i`), and the token keeps
|
|
3557
|
+
* its hover and navigation whichever comes first: a mapping without features
|
|
3558
|
+
* never takes the place of one with features. Of two with features, the first
|
|
3559
|
+
* is kept, so the spans that coalesce stay the same. The candidate is
|
|
3560
|
+
* position-only when one of its mappings is and none has a feature bit.
|
|
3561
|
+
*
|
|
3154
3562
|
* The transform emits container spans (statements, control-flow bodies) that
|
|
3155
3563
|
* enclose token spans. TypeScript requires generated spans to be disjoint, so
|
|
3156
3564
|
* candidates are ranked Verbatim first, then shorter before longer, and a
|
|
@@ -3179,6 +3587,13 @@ function to_span_mappings(mappings, generated_text, original_text, options = {})
|
|
|
3179
3587
|
const language_features = options.languageFeatures !== false;
|
|
3180
3588
|
/** @type {Candidate[]} */
|
|
3181
3589
|
const candidates = [];
|
|
3590
|
+
/**
|
|
3591
|
+
* Candidates by their generated and original ranges. Kept apart, two
|
|
3592
|
+
* candidates over the same ranges would tie in the ranking below, and the
|
|
3593
|
+
* first in the transform's order would win even without features.
|
|
3594
|
+
* @type {Map<string, Candidate>}
|
|
3595
|
+
*/
|
|
3596
|
+
const by_ranges = /* @__PURE__ */ new Map();
|
|
3182
3597
|
for (const mapping of mappings) {
|
|
3183
3598
|
const count = Math.min(mapping.sourceOffsets.length, mapping.generatedOffsets.length);
|
|
3184
3599
|
for (let index = 0; index < count; index++) {
|
|
@@ -3198,15 +3613,27 @@ function to_span_mappings(mappings, generated_text, original_text, options = {})
|
|
|
3198
3613
|
else if (is_whole_identifier(generated_text, generated_start, generated_end) && is_whole_token(original_text, original_start, original_end)) kind = SpanMapKind.Alias;
|
|
3199
3614
|
else if (is_partial_identifier(original_text, original_start, original_end)) continue;
|
|
3200
3615
|
else kind = SpanMapKind.Atom;
|
|
3201
|
-
|
|
3616
|
+
const features = language_features ? features_from_mapping_data(mapping.data) : SpanMapFeature.None;
|
|
3617
|
+
const position_only = is_position_only(mapping.data);
|
|
3618
|
+
const key = `${generated_start},${generated_end},${original_start},${original_end}`;
|
|
3619
|
+
const same = by_ranges.get(key);
|
|
3620
|
+
if (same) {
|
|
3621
|
+
if (same.features === SpanMapFeature.None) same.features = features;
|
|
3622
|
+
same.positionOnly = (same.positionOnly || position_only) && same.features === SpanMapFeature.None;
|
|
3623
|
+
continue;
|
|
3624
|
+
}
|
|
3625
|
+
/** @type {Candidate} */
|
|
3626
|
+
const candidate = {
|
|
3202
3627
|
generatedStart: generated_start,
|
|
3203
3628
|
generatedEnd: generated_end,
|
|
3204
3629
|
originalStart: original_start,
|
|
3205
3630
|
originalEnd: original_end,
|
|
3206
3631
|
kind,
|
|
3207
|
-
features
|
|
3208
|
-
positionOnly:
|
|
3209
|
-
}
|
|
3632
|
+
features,
|
|
3633
|
+
positionOnly: position_only
|
|
3634
|
+
};
|
|
3635
|
+
by_ranges.set(key, candidate);
|
|
3636
|
+
candidates.push(candidate);
|
|
3210
3637
|
}
|
|
3211
3638
|
}
|
|
3212
3639
|
candidates.sort((left, right) => Number(left.kind !== SpanMapKind.Verbatim) - Number(right.kind !== SpanMapKind.Verbatim) || left.generatedEnd - left.generatedStart - (right.generatedEnd - right.generatedStart) || left.generatedStart - right.generatedStart || left.originalStart - right.originalStart);
|
|
@@ -3986,4 +4413,4 @@ function nearest_package_manifest(entry) {
|
|
|
3986
4413
|
|
|
3987
4414
|
//#endregion
|
|
3988
4415
|
export { validate_options as i, require$1 as n, to_diagnostic as r, create_tsrx_content_mapper as t };
|
|
3989
|
-
//# sourceMappingURL=mapper-
|
|
4416
|
+
//# sourceMappingURL=mapper-CiYVAopk.js.map
|