diff --git a/crates/tsv_debug/src/cli/commands/gap_audit_known.txt b/crates/tsv_debug/src/cli/commands/gap_audit_known.txt index 8eb4251e8..194df1506 100644 --- a/crates/tsv_debug/src/cli/commands/gap_audit_known.txt +++ b/crates/tsv_debug/src/cli/commands/gap_audit_known.txt @@ -12,7 +12,7 @@ # the gate rather than being pinned. # # Format: KINDSHAPEPAYLOADS -# shapes: 570 +# shapes: 540 DROPPED !)⟨⟩!. annotation,block,jsdoc_cast DROPPED #⟨⟩IDENT annotation,block,jsdoc_cast,line,multiline DROPPED #⟨⟩\ annotation,block,jsdoc_cast,line,multiline @@ -61,8 +61,6 @@ DROPPED ()⟨⟩) annotation,block,jsdoc_cast,line,multiline DROPPED ()⟨⟩)); annotation,block,jsdoc_cast,line,multiline DROPPED ()⟨⟩); annotation,block,jsdoc_cast,line,multiline DROPPED ()⟨⟩␣ annotation,block,jsdoc_cast,line,multiline -DROPPED (++⟨⟩IDENT line -DROPPED (--⟨⟩IDENT line DROPPED (/)⟨⟩␣ annotation,block,jsdoc_cast DROPPED (<⟨⟩IDENT annotation,block,jsdoc_cast,multiline DROPPED ([(⟨⟩IDENT line @@ -110,7 +108,6 @@ DROPPED )⟨⟩) annotation,block,jsdoc_cast,line,multiline DROPPED )⟨⟩)); annotation,block,jsdoc_cast,line,multiline DROPPED )⟨⟩); annotation,block,jsdoc_cast,line,multiline DROPPED )⟨⟩)?] annotation,block,jsdoc_cast,line,multiline -DROPPED )⟨⟩++; annotation,block,jsdoc_cast DROPPED )⟨⟩, annotation,block,jsdoc_cast,line,multiline DROPPED )⟨⟩=> annotation,block,jsdoc_cast DROPPED )⟨⟩=>( annotation,block,jsdoc_cast @@ -131,12 +128,7 @@ DROPPED */,⟨⟩␣ annotation,block,jsdoc_cast DROPPED */⟨⟩, annotation,block,jsdoc_cast,line,multiline DROPPED */⟨⟩,/* line DROPPED */⟨⟩/* line,multiline -DROPPED ++(⟨⟩IDENT line -DROPPED ++(⟨⟩␣ line -DROPPED ++⟨⟩( annotation,block,line,multiline DROPPED ++⟨⟩); annotation,block,jsdoc_cast,multiline -DROPPED ++⟨⟩IDENT line -DROPPED ++⟨⟩␣ line DROPPED +⟨⟩IDENT line DROPPED +⟨⟩␣ annotation,block,jsdoc_cast,line,multiline DROPPED ,(⟨⟩IDENT annotation,block,jsdoc_cast,line,multiline @@ -157,9 +149,6 @@ DROPPED ,⟨⟩] annotation,block,jsdoc_cast,multiline DROPPED ,⟨⟩]); multiline DROPPED ,⟨⟩]; annotation,block,jsdoc_cast,multiline DROPPED ,⟨⟩␣ annotation,block,jsdoc_cast,line,multiline -DROPPED --⟨⟩IDENT line -DROPPED --⟨⟩␣ line -DROPPED -⟨⟩NUM annotation,block,jsdoc_cast,line,multiline DROPPED .#⟨⟩IDENT annotation,block,jsdoc_cast,line,multiline DROPPED .()⟨⟩)!( annotation,block,jsdoc_cast,line,multiline DROPPED .()⟨⟩)!` annotation,block,jsdoc_cast,line,multiline @@ -171,16 +160,12 @@ DROPPED :⟨⟩{ annotation,block,jsdoc_cast,multiline DROPPED :⟨⟩␣ annotation,block,jsdoc_cast,multiline DROPPED ;#⟨⟩IDENT annotation,block,jsdoc_cast,line,multiline DROPPED ;}⟨⟩} annotation,block,jsdoc_cast,line,multiline -DROPPED <-⟨⟩NUM annotation,block,jsdoc_cast,line,multiline DROPPED <⟨⟩IDENT annotation,block,jsdoc_cast,multiline DROPPED <⟨⟩const annotation,block,jsdoc_cast,multiline DROPPED <⟨⟩␣ annotation,block,jsdoc_cast,multiline DROPPED ="{⟨⟩IDENT annotation,block,jsdoc_cast,line,multiline DROPPED =(<⟨⟩IDENT annotation,block,jsdoc_cast,multiline DROPPED =(⟨⟩< line -DROPPED =++⟨⟩IDENT line -DROPPED =--⟨⟩IDENT line -DROPPED =-⟨⟩NUM annotation,block,jsdoc_cast,line,multiline DROPPED =<⟨⟩IDENT annotation,block,jsdoc_cast,multiline DROPPED =>(⟨⟩{ line DROPPED =>(⟨⟩{}) line @@ -236,25 +221,16 @@ DROPPED IDENT⟨⟩)!` annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩)) annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩)). annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩)); annotation,block,jsdoc_cast,line,multiline -DROPPED IDENT⟨⟩)++ annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩): annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩); annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩)=> annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩)} annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩+ annotation,block,jsdoc_cast,line,multiline -DROPPED IDENT⟨⟩++ annotation,block,jsdoc_cast -DROPPED IDENT⟨⟩++) annotation,block,jsdoc_cast -DROPPED IDENT⟨⟩++, annotation,block,jsdoc_cast -DROPPED IDENT⟨⟩++; annotation,block,jsdoc_cast -DROPPED IDENT⟨⟩++} annotation,block,jsdoc_cast DROPPED IDENT⟨⟩, annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩,/* line,multiline DROPPED IDENT⟨⟩,// line DROPPED IDENT⟨⟩,>( annotation,block,jsdoc_cast,multiline DROPPED IDENT⟨⟩,>/ annotation,block,jsdoc_cast,multiline -DROPPED IDENT⟨⟩-- annotation,block,jsdoc_cast -DROPPED IDENT⟨⟩--) annotation,block,jsdoc_cast -DROPPED IDENT⟨⟩--; annotation,block,jsdoc_cast DROPPED IDENT⟨⟩/ annotation,block,jsdoc_cast,line,multiline DROPPED IDENT⟨⟩/* line,multiline DROPPED IDENT⟨⟩: annotation,block,jsdoc_cast,line,multiline @@ -347,7 +323,6 @@ DROPPED ][⟨⟩]); annotation,block,jsdoc_cast,line,multiline DROPPED ][⟨⟩]; annotation,block,jsdoc_cast,line,multiline DROPPED ]⟨⟩) annotation,block,jsdoc_cast,line,multiline DROPPED ]⟨⟩); annotation,block,jsdoc_cast,multiline -DROPPED ]⟨⟩++; annotation,block,jsdoc_cast DROPPED ]⟨⟩/* line DROPPED ]⟨⟩: annotation,block,jsdoc_cast,line,multiline DROPPED ]⟨⟩[]) annotation,block,jsdoc_cast @@ -388,7 +363,6 @@ DROPPED void⟨⟩␣ annotation,block,jsdoc_cast DROPPED yield⟨⟩* annotation,block,jsdoc_cast,line,multiline DROPPED {#⟨⟩IDENT annotation,block,jsdoc_cast,line,multiline DROPPED {(<⟨⟩IDENT annotation,block,jsdoc_cast,multiline -DROPPED {++⟨⟩IDENT line DROPPED {})⟨⟩); annotation,block,jsdoc_cast,multiline DROPPED {},⟨⟩␣ annotation,block,jsdoc_cast,multiline DROPPED {}⟨⟩); annotation,block,jsdoc_cast,line,multiline @@ -442,7 +416,6 @@ DROPPED ␣⟨⟩) annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩)!` annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩)!} annotation,block,jsdoc_cast,multiline DROPPED ␣⟨⟩)( annotation,block,jsdoc_cast,multiline -DROPPED ␣⟨⟩)++ annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩), annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩). annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩)// annotation,block,jsdoc_cast,line,multiline @@ -452,13 +425,10 @@ DROPPED ␣⟨⟩)} annotation,block,jsdoc_cast,multiline DROPPED ␣⟨⟩)}' annotation,block,jsdoc_cast,multiline DROPPED ␣⟨⟩)}` annotation,block,jsdoc_cast,multiline DROPPED ␣⟨⟩+ annotation,block,jsdoc_cast,line,multiline -DROPPED ␣⟨⟩++ annotation,block,jsdoc_cast -DROPPED ␣⟨⟩++; annotation,block,jsdoc_cast DROPPED ␣⟨⟩, annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩,' annotation,block,jsdoc_cast DROPPED ␣⟨⟩,/* annotation,block,jsdoc_cast DROPPED ␣⟨⟩,]; annotation,block,jsdoc_cast -DROPPED ␣⟨⟩--; annotation,block,jsdoc_cast DROPPED ␣⟨⟩... multiline DROPPED ␣⟨⟩/ annotation,block,jsdoc_cast,line,multiline DROPPED ␣⟨⟩/* annotation,block,jsdoc_cast,line,multiline diff --git a/crates/tsv_ts/src/parser/expression_lookahead.rs b/crates/tsv_ts/src/parser/expression_lookahead.rs index 3a271ef02..186c9c3b6 100644 --- a/crates/tsv_ts/src/parser/expression_lookahead.rs +++ b/crates/tsv_ts/src/parser/expression_lookahead.rs @@ -8,7 +8,7 @@ // // All functions operate on byte slices for performance (no tokenization needed). -use super::scan::{is_identifier_start, skip_identifier, skip_whitespace_and_comments}; +use super::scan::{is_identifier_start, is_word_at, skip_identifier, skip_whitespace_and_comments}; use tsv_lang::source_scan::{TriviaProfile, is_regex_start, skip_regex_literal, skip_trivia}; /// `<` at `pos` is `<=` comparison operator, not an angle bracket open @@ -430,17 +430,10 @@ fn paren_list_then_arrow(bytes: &[u8], paren: usize) -> bool { /// past the `abstract` keyword. pub(super) fn is_construct_type_start(bytes: &[u8], pos: usize) -> bool { // Whole-word `new` (not an identifier like `newType`). - if !bytes[pos..].starts_with(b"new") { + if !is_word_at(bytes, pos, b"new") { return false; } - let after_new = pos + b"new".len(); - if bytes - .get(after_new) - .is_some_and(|&b| b.is_ascii_alphanumeric() || b == b'_' || b == b'$') - { - return false; - } - let paren = skip_whitespace_and_comments(bytes, after_new); + let paren = skip_whitespace_and_comments(bytes, pos + b"new".len()); if bytes.get(paren) != Some(&b'(') { return false; } diff --git a/crates/tsv_ts/src/parser/expression_type_args.rs b/crates/tsv_ts/src/parser/expression_type_args.rs index 12400df0d..b86897d02 100644 --- a/crates/tsv_ts/src/parser/expression_type_args.rs +++ b/crates/tsv_ts/src/parser/expression_type_args.rs @@ -6,7 +6,10 @@ use super::expression_lookahead::{ is_construct_type_start, is_function_type_start, is_generic_function_type_start, scan_for_closing_angle_bracket, }; -use super::scan::{is_identifier_start, skip_identifier, skip_whitespace_and_comments}; +use super::scan::{ + is_identifier_start, is_word_at, skip_identifier, skip_numeric_literal, + skip_whitespace_and_comments, +}; impl<'a, 'arena> Parser<'a, 'arena> { /// Check if current position starts type arguments: `` @@ -170,70 +173,82 @@ impl<'a, 'arena> Parser<'a, 'arena> { // starting at `pos` is equivalent to starting past the separator.) b'>' | b'<' | b',' | b'|' | b'&' => scan_for_closing_angle_bracket(bytes, pos), - // Indexed type vs array access: `T[K]` vs `arr[0]` - b'[' => self.check_indexed_type_pattern(bytes, pos), + // Indexed type vs array access: `T[K]` vs `arr[0]`. Confirmed by the same + // closing-`>` scan as the arms above — `T[K]` shaped bytes are equally a + // member access on a comparison's right operand, so only the matching `>` + // (and its follow token) tells them apart: `f(a < B[c], d)` and + // `a < B[c] > d` stay comparisons, `f(x)` is an instantiation. + b'[' => { + self.check_indexed_type_pattern(bytes, pos) + && scan_for_closing_angle_bracket(bytes, pos) + } - // Type constraint: `T extends U` - b'e' if bytes[pos..].starts_with(b"extends") => true, + // Type constraint: `T extends U`. Whole-word — an identifier that merely + // starts with `extends` is an ordinary operand (`a < b` ⏎ `extendsFoo()`, + // where ASI ends the statement) — and confirmed by the closing-`>` scan + // like every sibling arm. + b'e' if is_word_at(bytes, pos, b"extends") => { + scan_for_closing_angle_bracket(bytes, pos) + } _ => false, } } - /// Check if `[` at `pos` starts an indexed type (not array access). + /// Whether the `[` at `pos` can open an indexed-access type rather than an array + /// index. A pre-filter only: every shape that stays grammatical both ways is handed + /// to the caller's closing-`>` scan, which arbitrates. /// - /// - `arr[0]`: numeric index → array access - /// - `arr[i]` followed by `<` or `;`: array access - /// - `T[K]` followed by `>` or `,`: indexed type - /// - `T["key"]`, `T[keyof U]`, `T[typeof x]`: indexed type - /// - `a[b - 1]`: complex expression → array access (default) + /// - `T[]`, `T["key"]`, `T[keyof U]`, `T[typeof x]`: indexed type + /// - `T[K]`, `T[0]`, `T[-1]` followed by `>`, `,`, or another `[`: indexed type + /// - `T[A | B]`, `T[0 | 1]`, `T[A[B]]`, `T[A.B]`, `T[A]`, + /// `T[A extends B ? C : D]`: the index is itself a type, so the scan decides + /// - `a[b - 1]`, `a[0 + 1]`, `a[c || d]`, `a[c <= d]`: arithmetic, or a + /// logical/shift/relational operator — an expression, never a type → array access + /// - `a[-b]`: a unary negation, not a negative literal → array access fn check_indexed_type_pattern(&self, bytes: &[u8], pos: usize) -> bool { let inside = skip_whitespace_and_comments(bytes, pos + 1); - if inside >= bytes.len() { + let Some(&first) = bytes.get(inside) else { return false; - } + }; - // Empty brackets `T[]` — array type - if bytes[inside] == b']' { - return true; - } + match first { + // Empty brackets `T[]` — array type + b']' => true, - // Numeric index is definitely array access - if bytes[inside].is_ascii_digit() { - return false; - } + // Numeric literal index: `T[0]`, `T[-1]`, `T[0 | 1]`. A numeric literal is as + // valid a type as it is an array index, so the literal alone decides nothing — + // what FOLLOWS it does, under the same rule a reference index answers to. + b'0'..=b'9' | b'-' => { + let after_number = skip_numeric_literal(bytes, inside); + // No literal starts here at all (`-b`) — a unary negation, so the index is + // an expression. Guarding on this is what stops the `-` from swallowing an + // identifier and landing on the same `]` a real literal ends at. + if after_number == inside { + return false; + } + continues_as_type(bytes, skip_whitespace_and_comments(bytes, after_number)) + } - // Identifier index: check for type keywords then what follows `]` - if is_identifier_start(bytes[inside]) { - let after_id = skip_identifier(bytes, inside); + // String literal key: `T["key"]`, `T['key']` — indexed access type + b'\'' | b'"' | b'`' => true, - // Type operator keywords: `T[keyof U]`, `T[typeof x]` - let kw = &bytes[inside..after_id]; - if kw == b"keyof" || kw == b"typeof" { - return true; - } + // Identifier index: check for type keywords then what follows the identifier + _ if is_identifier_start(first) => { + let after_id = skip_identifier(bytes, inside); - let after_bracket = skip_whitespace_and_comments(bytes, after_id); - if after_bracket < bytes.len() && bytes[after_bracket] == b']' { - let after_close = skip_whitespace_and_comments(bytes, after_bracket + 1); - // Type args end with `>` or continue with `,` - if after_close < bytes.len() && matches!(bytes[after_close], b'>' | b',') { + // Type operator keywords: `T[keyof U]`, `T[typeof x]` + let kw = &bytes[inside..after_id]; + if kw == b"keyof" || kw == b"typeof" { return true; } - return false; + + continues_as_type(bytes, skip_whitespace_and_comments(bytes, after_id)) } - // Identifier followed by something other than `]` (e.g., `b - 1]`) - // is a complex expression — array access, not indexed type - return false; - } - // String literal key: `T["key"]`, `T['key']` — indexed access type - if matches!(bytes[inside], b'\'' | b'"' | b'`') { - return true; + // Unknown pattern — default to NOT type args (safer for JS expressions) + _ => false, } - - // Unknown pattern — default to NOT type args (safer for JS expressions) - false } /// Check if position points to a TypeScript type keyword. @@ -273,3 +288,35 @@ impl<'a, 'arena> Parser<'a, 'arena> { } } } + +/// Whether the byte at `after_operand` — the first non-trivia byte past an index operand — +/// continues a TYPE rather than an expression. +/// +/// Shared by both operand kinds, and it must stay shared: `T[K | J]` and `T[0 | 1]` are +/// the same question, and answering it in one place is what keeps a numeric index from +/// being read more narrowly than a reference one. +fn continues_as_type(bytes: &[u8], after_operand: usize) -> bool { + match bytes.get(after_operand) { + Some(b']') => { + let after_close = skip_whitespace_and_comments(bytes, after_operand + 1); + // Type args end with `>`, continue with `,`, or chain another index group + // (`T[K][J]`) — the caller's closing-`>` scan arbitrates all three + matches!(bytes.get(after_close), Some(b'>' | b',' | b'[')) + } + // `||` and `&&` are logical operators, so the index is an expression — only the + // single `|`/`&` are type operators (as in the caller's own arm). Likewise `<<` is + // a shift and `<=` a comparison, neither a type's `<`. + Some(b'|' | b'&') if bytes.get(after_operand + 1) == bytes.get(after_operand) => false, + Some(b'<') if matches!(bytes.get(after_operand + 1), Some(b'<' | b'=')) => false, + // Type-continuation tokens: the index is a union or intersection (`T[A | B]`), a + // nested index (`T[A[B]]`), a qualified name (`T[A.B]`), a generic reference + // (`T[A]`), or a conditional (`T[A extends B ? C : D]`). None of these can be + // arithmetic, so hand the decision to the caller's closing-`>` scan. + Some(b'|' | b'&' | b'[' | b'.' | b'<') => true, + Some(b'e') if is_word_at(bytes, after_operand, b"extends") => true, + // Anything else after the operand (e.g. `b - 1]`) is arithmetic — an expression, + // never a type, and the one case the closing-`>` scan cannot arbitrate + // (`a < arr[b - 1] > (c)` is grammatical both ways). + _ => false, + } +} diff --git a/crates/tsv_ts/src/parser/scan.rs b/crates/tsv_ts/src/parser/scan.rs index fddd55234..793e5c31c 100644 --- a/crates/tsv_ts/src/parser/scan.rs +++ b/crates/tsv_ts/src/parser/scan.rs @@ -96,6 +96,57 @@ pub(super) fn is_identifier_continue(b: u8) -> bool { b.is_ascii_alphanumeric() || b == b'_' || b == b'$' || b > 127 } +/// Check if `word` sits at `pos` as a whole identifier, not as the prefix of a longer +/// one — `is_word_at(b"extendsFoo", 0, b"extends")` is false. +/// +/// A bare `starts_with` is the trap this exists to close: the byte after the word decides +/// whether a lookahead is looking at a keyword or at an ordinary identifier that happens +/// to share its opening bytes. +#[inline] +pub(super) fn is_word_at(bytes: &[u8], pos: usize, word: &[u8]) -> bool { + bytes[pos..].starts_with(word) + && bytes + .get(pos + word.len()) + .is_none_or(|&b| !is_identifier_continue(b)) +} + +/// Skip a numeric literal, returning the position after it — or `pos` unchanged when no +/// literal starts there. Handles a leading `-` (the only sign a literal *type* may carry — +/// `A[+1]` is not one), radix prefixes (`0x`), separators (`1_000`), a BigInt `n`, and an +/// exponent whose own sign (`1e-3`) would otherwise end the scan. +/// +/// Deliberately loose about a literal's INTERIOR — it accepts more than the grammar does. +/// Callers use it to find where a literal ENDS, then check what follows, so over-consuming +/// a malformed literal only makes that follow-check fail. The FIRST character is the one +/// place it is strict, and must stay so: `-b` would otherwise scan as a literal ending at +/// the very `]` a real one ends at, leaving the follow-check no way to tell a negated +/// identifier from a negative number. +#[inline] +pub(super) fn skip_numeric_literal(bytes: &[u8], pos: usize) -> usize { + let mut cursor = pos; + if bytes.get(cursor) == Some(&b'-') { + cursor += 1; + } + // A literal starts with a digit, or a bare `.` for `-.5`. Anything else (`-b`, `-$b`) + // is a unary negation; reporting "nothing skipped" is how the caller learns that. + if !matches!(bytes.get(cursor), Some(b'0'..=b'9' | b'.')) { + return pos; + } + while cursor < bytes.len() { + let b = bytes[cursor]; + if b.is_ascii_alphanumeric() || b == b'.' || b == b'_' { + // An exponent's sign belongs to the literal, not to a following operator. + if matches!(b, b'e' | b'E') && matches!(bytes.get(cursor + 1), Some(b'-' | b'+')) { + cursor += 1; + } + cursor += 1; + } else { + break; + } + } + cursor +} + /// Skip an identifier, returning position after the identifier /// Assumes `pos` is at the start of an identifier #[inline] diff --git a/crates/tsv_ts/src/printer/expressions/operators.rs b/crates/tsv_ts/src/printer/expressions/operators.rs index 152a0a278..9849d5c84 100644 --- a/crates/tsv_ts/src/printer/expressions/operators.rs +++ b/crates/tsv_ts/src/printer/expressions/operators.rs @@ -83,13 +83,35 @@ impl<'a> Printer<'a> { argument_doc }; let operator_doc = d.text(update.operator.as_str()); + let operator_len = update.operator.as_str().len() as u32; if update.prefix { - // Prefix: ++x, --x - d.concat(&[operator_doc, argument_doc]) + // Prefix: ++x, --x. The operator→operand gap has no other emitter, so a + // comment authored there is dropped unless this builder claims it. Emit-axis, + // so a comment the operand OWNS (a glued block, an annotation, a JSDoc cast) + // returns `None` and keeps printing from the operand's own doc — claiming it + // here too would double-print it. + // + // `Adjacent`, not the `AdjacentGlued` of the assignment/call pull-up: an + // update operand is not a value gap, so prettier does not reflow the author's + // break after a glued block — `++/* c */⏎x` keeps the break. Gluing pulled the + // operand up to `++/* c */ x` instead. + let operator_end = update.span.start + operator_len; + match self.build_rhs_comments_opt(operator_end, update.argument.span().start) { + Some(comments) => d.concat(&[operator_doc, comments, argument_doc]), + None => d.concat(&[operator_doc, argument_doc]), + } } else { - // Postfix: x++, x-- - d.concat(&[argument_doc, operator_doc]) + // Postfix: x++, x--. Same unclaimed gap on the other side, and it can only + // ever hold a SINGLE-LINE block comment: a line comment or a multiline block + // is a line terminator for ASI, so `a // c⏎++` parses as `a;` then `++;` — + // never a postfix update, so the AST this prints can't contain one. That is + // why the comments emit inline here rather than hanging the operator: a break + // would rewrite the program. + let operator_start = update.span.end - operator_len; + let comments = + self.build_inline_comments_between_doc(update.argument.span().end, operator_start); + d.concat(&[argument_doc, comments, operator_doc]) } } diff --git a/crates/tsv_ts/src/printer/types/literal_types.rs b/crates/tsv_ts/src/printer/types/literal_types.rs index 7aeb4fd76..7d4099178 100644 --- a/crates/tsv_ts/src/printer/types/literal_types.rs +++ b/crates/tsv_ts/src/printer/types/literal_types.rs @@ -117,7 +117,28 @@ impl<'a> Printer<'a> { // For negative number types like `-1` let op = d.text(unary.operator.as_str()); let arg = self.build_expression_doc(unary.argument); - d.concat(&[op, arg]) + // The sign→numeral gap has no other emitter, so a comment authored there + // (`-/* c */ 1`) is dropped unless this builder claims it. Same seam as the + // value-level `build_unary_doc`, minus its paren re-adding: a parenthesized + // operand is only a *value* form, and `-(1)` is not a type — tsc reads `-` + // as a negative literal type only when the next token is a numeric/bigint + // literal, so prettier's comment-holding parens fail to re-parse. The + // in-place comment stays valid because that lookahead skips trivia. + // See docs/conformance_prettier.md §Comment relocation. + // + // Glued, unlike the `Adjacent` its update-expression sibling uses + // (`build_update_doc`): that gap HAS a prettier oracle and prettier keeps + // the author's break there, so it lives with two fixed points. Here + // prettier's output does not parse, so there is no oracle to match and + // the freer choice is the better one — gluing collapses every authoring + // (`-/* c */⏎1`, `- /* c */ 1`) onto the single fixed point `-/* c */ 1`. + // A negative literal type is one atom; splitting its sign across a line + // break buys nothing. + let operator_end = unary.span.start + unary.operator.as_str().len() as u32; + match self.build_rhs_comments_glued_opt(operator_end, unary.argument.span().start) { + Some(comments) => d.concat(&[op, comments, arg]), + None => d.concat(&[op, arg]), + } } } } diff --git a/docs/conformance_prettier.md b/docs/conformance_prettier.md index 710d21ebc..1e9c72330 100644 --- a/docs/conformance_prettier.md +++ b/docs/conformance_prettier.md @@ -40,6 +40,7 @@ Every `◆prettier_bug` — cases where Prettier produces output that is non-ide - `` — fails to collapse repeated whitespace — [svelte_element_class_whitespace](../tests/fixtures/svelte/special_elements/svelte_element_class_whitespace_prettier_divergence/) - Space after block element — strands a leading space, non-idempotent — [space_after_block](../tests/fixtures/svelte/elements/space_after_block_prettier_divergence/) - Constrained `infer … extends` operand parens — strips required parens → output fails to re-parse — [constrained_extends_parens](../tests/fixtures/typescript/types/infer/constrained_extends_parens_prettier_divergence/) +- Negative literal type sign comment (`-/* c */ 1`) — *adds* parens to hold the comment (`-(/* c */ 1)`), but no such type exists: `-` is a negative literal type only when the next token is a numeric/bigint literal → output fails to re-parse — [negative_literal_sign_comment](../tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/) - TS instantiation parens (`(x ? y : z)`) — strips parens, semantic change — [instantiation_parens](../tests/fixtures/typescript/typescript_specific/assertions/instantiation_parens_prettier_divergence/); the class-operand / `export default` case (`export default (class {})`) is worse still (strips → a class _declaration_) — [export_default_instantiation](../tests/fixtures/typescript/modules/exports/default_wrappable_leftmost_operators/instantiation_prettier_divergence/) - Svelte destructuring rename-with-default key drop (`{ a: b = 1 }` → `{ b = 1 }`) — semantic change — [each](../tests/fixtures/svelte/blocks/each/destructure_rename_default_prettier_divergence/), [await](../tests/fixtures/svelte/blocks/await/destructure_rename_default_prettier_divergence/) - `x?.#a` (optional chain to private field) — throws on valid input (pinned by `prettier_rejects.txt`) — [private_fields_optional_chain](../tests/fixtures/typescript/declarations/class/private_fields_optional_chain_prettier_divergence/) @@ -795,6 +796,7 @@ Prettier moves comments between syntactic boundaries into adjacent blocks, paren - Ternary operand to operator (≥2 line comments; test→`?`, consequent→`:`) → Every comment after the first relocated across the operator (`cond // c1⏎ ? // c2`); tsv keeps each before the operator on its own line — [consecutive_operand_comment](../tests/fixtures/typescript/expressions/ternary/consecutive_operand_comment_prettier_divergence/) - Ternary operator→branch **block** comment, authored trailing the operand's line (`cond ? x : /* c */⏎y`) → Across the operator, onto the preceding operand (`cond ? x /* c */ : y`), changing its association from the branch it precedes to that operand; tsv keeps it after the operator and collapses inline. Prettier's attachment claims the comment as leading of the branch only when it is *not* on the preceding node's line, so sharing that line makes it trailing of the operand instead. Both slots (`?` and `:`) behave alike, and the relocated form is dual-stable — pinned `variant_trailing`. The **own-line** authoring is a *pass-count* gap, not a relocation: prettier reaches tsv's fixed point non-idempotently (first pass breaks the whole conditional on the authored newline), pinned `prettier_intermediate_own_line` reconverging to input — [operand_block_comment_relocation](../tests/fixtures/typescript/expressions/ternary/operand_block_comment_relocation_prettier_divergence/) - Conditional-type branch block comment (same shape, type level; `B extends C ? /* c */ D : E`) → Across the operator (`B extends C /* c */ ? D : E`); tsv preserves. Same `variant_trailing` + `prettier_intermediate_own_line` pinning as its expression twin — [branch_block_comment_relocation](../tests/fixtures/typescript/types/conditional/branch_block_comment_relocation_prettier_divergence/) +- Negative literal type, sign→numeral (`-/* c */ 1`) → ◆prettier_bug ◆content_preservation — into parens around the numeral (`-(/* c */ 1)`), a type that does not exist: tsc reads `-` as a negative literal type only when the next token is a numeric/bigint literal, so the output fails to re-parse. tsv preserves in place, which stays valid because the lookahead's `nextToken()` skips trivia. Not preserving drops the comment — the position has no other emitter — [negative_literal_sign_comment](../tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/) - Switch empty body → Discriminant parens — [empty_comment](../tests/fixtures/typescript/statements/switch/empty_comment_prettier_divergence/) - Switch case before `{` → After opening brace (prettier non-idempotent, 2-3 passes) — [case_block_comment](../tests/fixtures/typescript/statements/switch/case_block_comment_prettier_divergence/) - Switch discriminant trailing → Switch body — [discriminant_trailing_comment](../tests/fixtures/typescript/statements/switch/discriminant_trailing_comment_prettier_divergence/) diff --git a/docs/conformance_svelte.md b/docs/conformance_svelte.md index 6c6c21df2..cb959c694 100644 --- a/docs/conformance_svelte.md +++ b/docs/conformance_svelte.md @@ -222,10 +222,13 @@ Svelte ❌ / Prettier ✅ / tsv ✅ in every case below: - An **invalid** v-flag regex (`/[a-z--[aeiou]]/v` — a range is not a `ClassSetOperand`, so V8 throws too): tsv accepts it by deferring the `IsValidRegularExpressionLiteral` early error, since regex bodies are opaque. Svelte is *correct* to reject; this is not a `v`-flag gap — [unicode_sets_advanced](../tests/fixtures/typescript/expressions/literals/regex/unicode_sets_advanced_svelte_divergence/) - `export default class implements I {}` (anonymous default class, implements-first heritage) — [export_default_implements](../tests/fixtures/typescript/declarations/class/export_default_implements_svelte_divergence/) - A cast as the left operand of `**` (`x as number ** 2`) — see below; the rejection itself is not pinnable +- A `>=` following a `<` operand (`a < b >= d`) — see below — [relational_lt_greater_equal](../tests/fixtures/typescript/expressions/binary/relational_lt_greater_equal_svelte_divergence/) - Async generic arrow params — see fixtures below **`using` keyword-name comments**: tsv **accepts** a comment between `using` and the binding name (`using /* c */ x = fn()`) and round-trips it, which is correct — per ecma262 §sec-comments a comment "behave[s] like white space and [is] discarded", so any two tokens may be separated by one. A comment *containing a line terminator* is the exception the same clause names: it counts as a `LineTerminator`, which the `[no LineTerminator here]` in `await [no LT] using` and `using [no LT] BindingIdentifier` then demotes — so `await /* c⏎ */ using x = fn()` correctly fails to read as a declaration. acorn's verdict is not comparable here: it rejects `using` / `await using` outright (see the list above), so it never reaches the comment question. +**`>=` after a `<` operand**: acorn-typescript rejects `a < b >= d` and `a < B[c] >= d` (`Assigning to rvalue`). It rescans the `>=` into `>` + `=`, closes a type-argument list on the `>`, and reads the `=` as an assignment to the resulting instantiation expression. tsc does not: its `canFollowTypeArgumentsInExpression` disqualifies the type-argument reading here, so the `<` stays relational and the `>=` stays one operator. Prettier agrees — it reprints the unspaced `a=d` as `a < b >= d`, which it would not do for an instantiation — and tsv matches tsc and prettier. Both operand forms are pinned because they take different paths through tsv's type-argument lookahead (bare identifier vs indexed member access). **Upstream candidate**: acorn-typescript `>=` rescan at a type-argument close. + **Cast as the left operand of `**`**: acorn-typescript rejects `x as number ** 2` / `x satisfies number ** 2` (`Unexpected token` at the `**`). tsc accepts both — it parses the cast as the `**` left operand, and its "unary expression is not allowed in the left-hand side of an exponentiation expression" grammar error (TS17006) fires only for a *prefix-unary* operand (`-2 ** 3`), not for a cast. Prettier agrees, printing `(x as number) ** 2`, and tsv matches. **Upstream candidate**: acorn-typescript exponentiation after `as`/`satisfies`. The rejection is the one case here that **cannot be pinned**. The `expected_svelte.json` = `{"error": "failed to parse"}` sentinel every fixture above uses attaches to `input.*`, and an `input.*` must be a formatting fixed point (F1) — `x as number ** 2` is not one, since both formatters normalize it to `(x as number) ** 2`. The source form can therefore only live in an `unformatted_*` variant, and the validator runs the canonical parser over `input.*` and `input_invalid_*` only, never over variants. So [as_satisfies_exponentiation](../tests/fixtures/typescript/expressions/as_satisfies_exponentiation/) is a *regular* fixture: it pins the parse shape and the paren insertion (both operand sides — a cast on the right needs parens too, since `as` otherwise binds looser and takes the whole exponentiation), and its `unformatted_no_parens` variant carries the source form. That variant formats at all only because prettier-plugin-svelte re-parses ` diff --git a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/expected.json b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/expected.json index 49d35f535..c60899088 100644 --- a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/expected.json +++ b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/expected.json @@ -2,7 +2,7 @@ "css": null, "js": [], "start": 0, - "end": 1938, + "end": 4514, "type": "Root", "fragment": { "type": "Fragment", @@ -140,9 +140,9 @@ }, { "type": "Line", - "value": " genuine instantiation with a literal/keyword/object/tuple/numeric type arg, or a", + "value": " an indexed member access after `<` is a comparison operand, not an indexed access", "start": 1161, - "end": 1244, + "end": 1245, "loc": { "start": { "line": 37, @@ -150,15 +150,15 @@ }, "end": { "line": 37, - "column": 84 + "column": 85 } } }, { "type": "Line", - "value": " function type with an optional param, still parses as type arguments", - "start": 1246, - "end": 1317, + "value": " type; the `,` that follows it belongs to the enclosing argument, element, or", + "start": 1247, + "end": 1326, "loc": { "start": { "line": 38, @@ -166,6 +166,182 @@ }, "end": { "line": 38, + "column": 80 + } + } + }, + { + "type": "Line", + "value": " property list, whatever the index is", + "start": 1328, + "end": 1367, + "loc": { + "start": { + "line": 39, + "column": 1 + }, + "end": { + "line": 39, + "column": 40 + } + } + }, + { + "type": "Line", + "value": " richer index contents are comparison operands too when no `>` closes the list", + "start": 1576, + "end": 1656, + "loc": { + "start": { + "line": 49, + "column": 1 + }, + "end": { + "line": 49, + "column": 81 + } + } + }, + { + "type": "Line", + "value": " arithmetic inside the index is not a type, so the list stays a comparison even", + "start": 1826, + "end": 1907, + "loc": { + "start": { + "line": 59, + "column": 1 + }, + "end": { + "line": 59, + "column": 82 + } + } + }, + { + "type": "Line", + "value": " when a `>` closes it; a negated operand and the logical and relational operators", + "start": 1909, + "end": 1992, + "loc": { + "start": { + "line": 60, + "column": 1 + }, + "end": { + "line": 60, + "column": 84 + } + } + }, + { + "type": "Line", + "value": " are expressions too, never types", + "start": 1994, + "end": 2029, + "loc": { + "start": { + "line": 61, + "column": 1 + }, + "end": { + "line": 61, + "column": 36 + } + } + }, + { + "type": "Line", + "value": " a `>` or a shift operator after the indexed operand continues the comparison", + "start": 2159, + "end": 2238, + "loc": { + "start": { + "line": 67, + "column": 1 + }, + "end": { + "line": 67, + "column": 80 + } + } + }, + { + "type": "Line", + "value": " chain — the `>` run belongs to the operator, not to a type-argument close", + "start": 2240, + "end": 2316, + "loc": { + "start": { + "line": 68, + "column": 1 + }, + "end": { + "line": 68, + "column": 77 + } + } + }, + { + "type": "Line", + "value": " an identifier that merely starts with `extends` is a fresh statement on the next", + "start": 2403, + "end": 2486, + "loc": { + "start": { + "line": 73, + "column": 1 + }, + "end": { + "line": 73, + "column": 84 + } + } + }, + { + "type": "Line", + "value": " line (ASI), not a type constraint", + "start": 2488, + "end": 2524, + "loc": { + "start": { + "line": 74, + "column": 1 + }, + "end": { + "line": 74, + "column": 37 + } + } + }, + { + "type": "Line", + "value": " genuine instantiation with a literal/keyword/object/tuple/numeric type arg, or a", + "start": 2562, + "end": 2645, + "loc": { + "start": { + "line": 78, + "column": 1 + }, + "end": { + "line": 78, + "column": 84 + } + } + }, + { + "type": "Line", + "value": " function type with an optional param, still parses as type arguments", + "start": 2647, + "end": 2718, + "loc": { + "start": { + "line": 79, + "column": 1 + }, + "end": { + "line": 79, "column": 72 } } @@ -173,15 +349,15 @@ { "type": "Line", "value": " a generic nested inside a tuple or object-type arg still parses as type arguments", - "start": 1505, - "end": 1589, + "start": 2906, + "end": 2990, "loc": { "start": { - "line": 47, + "line": 88, "column": 1 }, "end": { - "line": 47, + "line": 88, "column": 85 } } @@ -189,15 +365,15 @@ { "type": "Line", "value": " a template literal after the closing `>` is a tagged template on the", - "start": 1797, - "end": 1868, + "start": 3198, + "end": 3269, "loc": { "start": { - "line": 56, + "line": 97, "column": 1 }, "end": { - "line": 56, + "line": 97, "column": 72 } } @@ -205,36 +381,148 @@ { "type": "Line", "value": " instantiation, not a comparison", - "start": 1870, - "end": 1904, + "start": 3271, + "end": 3305, "loc": { "start": { - "line": 57, + "line": 98, "column": 1 }, "end": { - "line": 57, + "line": 98, "column": 35 } } + }, + { + "type": "Line", + "value": " an indexed access, array, or conditional type argument still parses as type", + "start": 3331, + "end": 3409, + "loc": { + "start": { + "line": 101, + "column": 1 + }, + "end": { + "line": 101, + "column": 79 + } + } + }, + { + "type": "Line", + "value": " arguments — the closing `>` is followed by a call", + "start": 3411, + "end": 3463, + "loc": { + "start": { + "line": 102, + "column": 1 + }, + "end": { + "line": 102, + "column": 53 + } + } + }, + { + "type": "Line", + "value": " every index content that is itself a valid type — union, intersection, nested", + "start": 3676, + "end": 3756, + "loc": { + "start": { + "line": 111, + "column": 1 + }, + "end": { + "line": 111, + "column": 81 + } + } + }, + { + "type": "Line", + "value": " index, numeric literal, and conditional — makes the list type arguments", + "start": 3758, + "end": 3832, + "loc": { + "start": { + "line": 112, + "column": 1 + }, + "end": { + "line": 112, + "column": 75 + } + } + }, + { + "type": "Line", + "value": " a numeric literal index continues into a type exactly as a reference index does —", + "start": 4100, + "end": 4184, + "loc": { + "start": { + "line": 123, + "column": 1 + }, + "end": { + "line": 123, + "column": 85 + } + } + }, + { + "type": "Line", + "value": " union, intersection, and conditional forms are type arguments whichever operand", + "start": 4186, + "end": 4268, + "loc": { + "start": { + "line": 124, + "column": 1 + }, + "end": { + "line": 124, + "column": 83 + } + } + }, + { + "type": "Line", + "value": " kind opens them, and an exponent's own sign belongs to the literal", + "start": 4270, + "end": 4339, + "loc": { + "start": { + "line": 125, + "column": 1 + }, + "end": { + "line": 125, + "column": 70 + } + } } ], "instance": { "type": "Script", "start": 0, - "end": 1937, + "end": 4513, "context": "default", "content": { "type": "Program", "start": 18, - "end": 1928, + "end": 4504, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 59, + "line": 131, "column": 9 } }, @@ -3268,126 +3556,8370 @@ "kind": "const" }, { - "type": "VariableDeclaration", - "start": 1319, - "end": 1340, + "type": "ExpressionStatement", + "start": 1369, + "end": 1385, "loc": { "start": { - "line": 39, + "line": 40, "column": 1 }, "end": { - "line": 39, - "column": 22 + "line": 40, + "column": 17 } }, - "declarations": [ - { - "type": "VariableDeclarator", - "start": 1325, - "end": 1339, + "expression": { + "type": "CallExpression", + "start": 1369, + "end": 1384, + "loc": { + "start": { + "line": 40, + "column": 1 + }, + "end": { + "line": 40, + "column": 16 + } + }, + "callee": { + "type": "Identifier", + "start": 1369, + "end": 1371, "loc": { "start": { - "line": 39, - "column": 7 + "line": 40, + "column": 1 }, "end": { - "line": 39, - "column": 21 + "line": 40, + "column": 3 } }, - "id": { - "type": "Identifier", - "start": 1325, - "end": 1327, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1372, + "end": 1380, "loc": { "start": { - "line": 39, - "column": 7 + "line": 40, + "column": 4 }, "end": { - "line": 39, - "column": 9 - } - }, - "name": "b1" - }, - "init": { - "type": "CallExpression", - "start": 1330, - "end": 1339, - "loc": { - "start": { - "line": 39, + "line": 40, "column": 12 - }, - "end": { - "line": 39, - "column": 21 } }, - "callee": { + "left": { "type": "Identifier", - "start": 1330, - "end": 1332, + "start": 1372, + "end": 1373, "loc": { "start": { - "line": 39, - "column": 12 + "line": 40, + "column": 4 }, "end": { - "line": 39, - "column": 14 + "line": 40, + "column": 5 } }, - "name": "fn" + "name": "a" }, - "arguments": [], - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1332, - "end": 1337, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1376, + "end": 1380, "loc": { "start": { - "line": 39, - "column": 14 + "line": 40, + "column": 8 }, "end": { - "line": 39, - "column": 19 + "line": 40, + "column": 12 } }, - "params": [ - { - "type": "TSLiteralType", - "start": 1333, - "end": 1336, - "loc": { - "start": { - "line": 39, - "column": 15 - }, - "end": { - "line": 39, + "object": { + "type": "Identifier", + "start": 1376, + "end": 1377, + "loc": { + "start": { + "line": 40, + "column": 8 + }, + "end": { + "line": 40, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 1378, + "end": 1379, + "loc": { + "start": { + "line": 40, + "column": 10 + }, + "end": { + "line": 40, + "column": 11 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1382, + "end": 1383, + "loc": { + "start": { + "line": 40, + "column": 14 + }, + "end": { + "line": 40, + "column": 15 + } + }, + "name": "d" + } + ], + "optional": false + }, + "leadingComments": [ + { + "type": "Line", + "value": " an indexed member access after `<` is a comparison operand, not an indexed access", + "start": 1161, + "end": 1245 + }, + { + "type": "Line", + "value": " type; the `,` that follows it belongs to the enclosing argument, element, or", + "start": 1247, + "end": 1326 + }, + { + "type": "Line", + "value": " property list, whatever the index is", + "start": 1328, + "end": 1367 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 1387, + "end": 1405, + "loc": { + "start": { + "line": 41, + "column": 1 + }, + "end": { + "line": 41, + "column": 19 + } + }, + "expression": { + "type": "CallExpression", + "start": 1387, + "end": 1404, + "loc": { + "start": { + "line": 41, + "column": 1 + }, + "end": { + "line": 41, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 1387, + "end": 1389, + "loc": { + "start": { + "line": 41, + "column": 1 + }, + "end": { + "line": 41, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1390, + "end": 1400, + "loc": { + "start": { + "line": 41, + "column": 4 + }, + "end": { + "line": 41, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 1390, + "end": 1391, + "loc": { + "start": { + "line": 41, + "column": 4 + }, + "end": { + "line": 41, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1394, + "end": 1400, + "loc": { + "start": { + "line": 41, + "column": 8 + }, + "end": { + "line": 41, + "column": 14 + } + }, + "object": { + "type": "Identifier", + "start": 1394, + "end": 1395, + "loc": { + "start": { + "line": 41, + "column": 8 + }, + "end": { + "line": 41, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "Literal", + "start": 1396, + "end": 1399, + "loc": { + "start": { + "line": 41, + "column": 10 + }, + "end": { + "line": 41, + "column": 13 + } + }, + "value": "k", + "raw": "'k'" + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1402, + "end": 1403, + "loc": { + "start": { + "line": 41, + "column": 16 + }, + "end": { + "line": 41, + "column": 17 + } + }, + "name": "d" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1407, + "end": 1430, + "loc": { + "start": { + "line": 42, + "column": 1 + }, + "end": { + "line": 42, + "column": 24 + } + }, + "expression": { + "type": "CallExpression", + "start": 1407, + "end": 1429, + "loc": { + "start": { + "line": 42, + "column": 1 + }, + "end": { + "line": 42, + "column": 23 + } + }, + "callee": { + "type": "Identifier", + "start": 1407, + "end": 1409, + "loc": { + "start": { + "line": 42, + "column": 1 + }, + "end": { + "line": 42, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1410, + "end": 1425, + "loc": { + "start": { + "line": 42, + "column": 4 + }, + "end": { + "line": 42, + "column": 19 + } + }, + "left": { + "type": "Identifier", + "start": 1410, + "end": 1411, + "loc": { + "start": { + "line": 42, + "column": 4 + }, + "end": { + "line": 42, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1414, + "end": 1425, + "loc": { + "start": { + "line": 42, + "column": 8 + }, + "end": { + "line": 42, + "column": 19 + } + }, + "object": { + "type": "Identifier", + "start": 1414, + "end": 1415, + "loc": { + "start": { + "line": 42, + "column": 8 + }, + "end": { + "line": 42, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "UnaryExpression", + "start": 1416, + "end": 1424, + "loc": { + "start": { + "line": 42, + "column": 10 + }, + "end": { + "line": 42, + "column": 18 + } + }, + "operator": "typeof", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 1423, + "end": 1424, + "loc": { + "start": { + "line": 42, + "column": 17 + }, + "end": { + "line": 42, "column": 18 } }, - "literal": { - "type": "Literal", - "start": 1333, - "end": 1336, + "name": "c" + } + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1427, + "end": 1428, + "loc": { + "start": { + "line": 42, + "column": 21 + }, + "end": { + "line": 42, + "column": 22 + } + }, + "name": "d" + } + ], + "optional": false + } + }, + { + "type": "VariableDeclaration", + "start": 1432, + "end": 1458, + "loc": { + "start": { + "line": 43, + "column": 1 + }, + "end": { + "line": 43, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 1438, + "end": 1457, + "loc": { + "start": { + "line": 43, + "column": 7 + }, + "end": { + "line": 43, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 1438, + "end": 1441, + "loc": { + "start": { + "line": 43, + "column": 7 + }, + "end": { + "line": 43, + "column": 10 + } + }, + "name": "a23" + }, + "init": { + "type": "ArrayExpression", + "start": 1444, + "end": 1457, + "loc": { + "start": { + "line": 43, + "column": 13 + }, + "end": { + "line": 43, + "column": 26 + } + }, + "elements": [ + { + "type": "BinaryExpression", + "start": 1445, + "end": 1453, + "loc": { + "start": { + "line": 43, + "column": 14 + }, + "end": { + "line": 43, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 1445, + "end": 1446, + "loc": { + "start": { + "line": 43, + "column": 14 + }, + "end": { + "line": 43, + "column": 15 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1449, + "end": 1453, + "loc": { + "start": { + "line": 43, + "column": 18 + }, + "end": { + "line": 43, + "column": 22 + } + }, + "object": { + "type": "Identifier", + "start": 1449, + "end": 1450, + "loc": { + "start": { + "line": 43, + "column": 18 + }, + "end": { + "line": 43, + "column": 19 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 1451, + "end": 1452, + "loc": { + "start": { + "line": 43, + "column": 20 + }, + "end": { + "line": 43, + "column": 21 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1455, + "end": 1456, + "loc": { + "start": { + "line": 43, + "column": 24 + }, + "end": { + "line": 43, + "column": 25 + } + }, + "name": "d" + } + ] + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 1460, + "end": 1494, + "loc": { + "start": { + "line": 44, + "column": 1 + }, + "end": { + "line": 44, + "column": 35 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 1466, + "end": 1493, + "loc": { + "start": { + "line": 44, + "column": 7 + }, + "end": { + "line": 44, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 1466, + "end": 1469, + "loc": { + "start": { + "line": 44, + "column": 7 + }, + "end": { + "line": 44, + "column": 10 + } + }, + "name": "a24" + }, + "init": { + "type": "ObjectExpression", + "start": 1472, + "end": 1493, + "loc": { + "start": { + "line": 44, + "column": 13 + }, + "end": { + "line": 44, + "column": 34 + } + }, + "properties": [ + { + "type": "Property", + "start": 1474, + "end": 1485, + "loc": { + "start": { + "line": 44, + "column": 15 + }, + "end": { + "line": 44, + "column": 26 + } + }, + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 1474, + "end": 1475, + "loc": { + "start": { + "line": 44, + "column": 15 + }, + "end": { + "line": 44, + "column": 16 + } + }, + "name": "a" + }, + "value": { + "type": "BinaryExpression", + "start": 1477, + "end": 1485, + "loc": { + "start": { + "line": 44, + "column": 18 + }, + "end": { + "line": 44, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 1477, + "end": 1478, + "loc": { + "start": { + "line": 44, + "column": 18 + }, + "end": { + "line": 44, + "column": 19 + } + }, + "name": "b" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1481, + "end": 1485, + "loc": { + "start": { + "line": 44, + "column": 22 + }, + "end": { + "line": 44, + "column": 26 + } + }, + "object": { + "type": "Identifier", + "start": 1481, + "end": 1482, + "loc": { + "start": { + "line": 44, + "column": 22 + }, + "end": { + "line": 44, + "column": 23 + } + }, + "name": "C" + }, + "property": { + "type": "Identifier", + "start": 1483, + "end": 1484, + "loc": { + "start": { + "line": 44, + "column": 24 + }, + "end": { + "line": 44, + "column": 25 + } + }, + "name": "d" + }, + "computed": true, + "optional": false + } + }, + "kind": "init" + }, + { + "type": "Property", + "start": 1487, + "end": 1491, + "loc": { + "start": { + "line": 44, + "column": 28 + }, + "end": { + "line": 44, + "column": 32 + } + }, + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 1487, + "end": 1488, + "loc": { + "start": { + "line": 44, + "column": 28 + }, + "end": { + "line": 44, + "column": 29 + } + }, + "name": "e" + }, + "value": { + "type": "Identifier", + "start": 1490, + "end": 1491, + "loc": { + "start": { + "line": 44, + "column": 31 + }, + "end": { + "line": 44, + "column": 32 + } + }, + "name": "f" + }, + "kind": "init" + } + ] + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 1496, + "end": 1522, + "loc": { + "start": { + "line": 45, + "column": 1 + }, + "end": { + "line": 45, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 1502, + "end": 1521, + "loc": { + "start": { + "line": 45, + "column": 7 + }, + "end": { + "line": 45, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 1502, + "end": 1505, + "loc": { + "start": { + "line": 45, + "column": 7 + }, + "end": { + "line": 45, + "column": 10 + } + }, + "name": "a25" + }, + "init": { + "type": "SequenceExpression", + "start": 1509, + "end": 1520, + "loc": { + "start": { + "line": 45, + "column": 14 + }, + "end": { + "line": 45, + "column": 25 + } + }, + "expressions": [ + { + "type": "BinaryExpression", + "start": 1509, + "end": 1517, + "loc": { + "start": { + "line": 45, + "column": 14 + }, + "end": { + "line": 45, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 1509, + "end": 1510, + "loc": { + "start": { + "line": 45, + "column": 14 + }, + "end": { + "line": 45, + "column": 15 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1513, + "end": 1517, + "loc": { + "start": { + "line": 45, + "column": 18 + }, + "end": { + "line": 45, + "column": 22 + } + }, + "object": { + "type": "Identifier", + "start": 1513, + "end": 1514, + "loc": { + "start": { + "line": 45, + "column": 18 + }, + "end": { + "line": 45, + "column": 19 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 1515, + "end": 1516, + "loc": { + "start": { + "line": 45, + "column": 20 + }, + "end": { + "line": 45, + "column": 21 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1519, + "end": 1520, + "loc": { + "start": { + "line": 45, + "column": 24 + }, + "end": { + "line": 45, + "column": 25 + } + }, + "name": "d" + } + ] + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 1524, + "end": 1547, + "loc": { + "start": { + "line": 46, + "column": 1 + }, + "end": { + "line": 46, + "column": 24 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 1530, + "end": 1546, + "loc": { + "start": { + "line": 46, + "column": 7 + }, + "end": { + "line": 46, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 1530, + "end": 1533, + "loc": { + "start": { + "line": 46, + "column": 7 + }, + "end": { + "line": 46, + "column": 10 + } + }, + "name": "a26" + }, + "init": { + "type": "BinaryExpression", + "start": 1536, + "end": 1546, + "loc": { + "start": { + "line": 46, + "column": 13 + }, + "end": { + "line": 46, + "column": 23 + } + }, + "left": { + "type": "Identifier", + "start": 1536, + "end": 1537, + "loc": { + "start": { + "line": 46, + "column": 13 + }, + "end": { + "line": 46, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1540, + "end": 1546, + "loc": { + "start": { + "line": 46, + "column": 17 + }, + "end": { + "line": 46, + "column": 23 + } + }, + "object": { + "type": "MemberExpression", + "start": 1540, + "end": 1543, + "loc": { + "start": { + "line": 46, + "column": 17 + }, + "end": { + "line": 46, + "column": 20 + } + }, + "object": { + "type": "Identifier", + "start": 1540, + "end": 1541, + "loc": { + "start": { + "line": 46, + "column": 17 + }, + "end": { + "line": 46, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 1542, + "end": 1543, + "loc": { + "start": { + "line": 46, + "column": 19 + }, + "end": { + "line": 46, + "column": 20 + } + }, + "name": "C" + }, + "computed": false, + "optional": false + }, + "property": { + "type": "Identifier", + "start": 1544, + "end": 1545, + "loc": { + "start": { + "line": 46, + "column": 21 + }, + "end": { + "line": 46, + "column": 22 + } + }, + "name": "d" + }, + "computed": true, + "optional": false + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 1549, + "end": 1573, + "loc": { + "start": { + "line": 47, + "column": 1 + }, + "end": { + "line": 47, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 1555, + "end": 1572, + "loc": { + "start": { + "line": 47, + "column": 7 + }, + "end": { + "line": 47, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 1555, + "end": 1558, + "loc": { + "start": { + "line": 47, + "column": 7 + }, + "end": { + "line": 47, + "column": 10 + } + }, + "name": "a27" + }, + "init": { + "type": "BinaryExpression", + "start": 1561, + "end": 1572, + "loc": { + "start": { + "line": 47, + "column": 13 + }, + "end": { + "line": 47, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 1561, + "end": 1562, + "loc": { + "start": { + "line": 47, + "column": 13 + }, + "end": { + "line": 47, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1565, + "end": 1572, + "loc": { + "start": { + "line": 47, + "column": 17 + }, + "end": { + "line": 47, + "column": 24 + } + }, + "object": { + "type": "MemberExpression", + "start": 1565, + "end": 1569, + "loc": { + "start": { + "line": 47, + "column": 17 + }, + "end": { + "line": 47, + "column": 21 + } + }, + "object": { + "type": "Identifier", + "start": 1565, + "end": 1566, + "loc": { + "start": { + "line": 47, + "column": 17 + }, + "end": { + "line": 47, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 1567, + "end": 1568, + "loc": { + "start": { + "line": 47, + "column": 19 + }, + "end": { + "line": 47, + "column": 20 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + }, + "property": { + "type": "Identifier", + "start": 1570, + "end": 1571, + "loc": { + "start": { + "line": 47, + "column": 22 + }, + "end": { + "line": 47, + "column": 23 + } + }, + "name": "e" + }, + "computed": true, + "optional": false + } + } + } + ], + "kind": "const" + }, + { + "type": "ExpressionStatement", + "start": 1658, + "end": 1678, + "loc": { + "start": { + "line": 50, + "column": 1 + }, + "end": { + "line": 50, + "column": 21 + } + }, + "expression": { + "type": "CallExpression", + "start": 1658, + "end": 1677, + "loc": { + "start": { + "line": 50, + "column": 1 + }, + "end": { + "line": 50, + "column": 20 + } + }, + "callee": { + "type": "Identifier", + "start": 1658, + "end": 1660, + "loc": { + "start": { + "line": 50, + "column": 1 + }, + "end": { + "line": 50, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1661, + "end": 1673, + "loc": { + "start": { + "line": 50, + "column": 4 + }, + "end": { + "line": 50, + "column": 16 + } + }, + "left": { + "type": "Identifier", + "start": 1661, + "end": 1662, + "loc": { + "start": { + "line": 50, + "column": 4 + }, + "end": { + "line": 50, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1665, + "end": 1673, + "loc": { + "start": { + "line": 50, + "column": 8 + }, + "end": { + "line": 50, + "column": 16 + } + }, + "object": { + "type": "Identifier", + "start": 1665, + "end": 1666, + "loc": { + "start": { + "line": 50, + "column": 8 + }, + "end": { + "line": 50, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "BinaryExpression", + "start": 1667, + "end": 1672, + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 50, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 1667, + "end": 1668, + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 50, + "column": 11 + } + }, + "name": "c" + }, + "operator": "|", + "right": { + "type": "Identifier", + "start": 1671, + "end": 1672, + "loc": { + "start": { + "line": 50, + "column": 14 + }, + "end": { + "line": 50, + "column": 15 + } + }, + "name": "d" + } + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1675, + "end": 1676, + "loc": { + "start": { + "line": 50, + "column": 18 + }, + "end": { + "line": 50, + "column": 19 + } + }, + "name": "e" + } + ], + "optional": false + }, + "leadingComments": [ + { + "type": "Line", + "value": " richer index contents are comparison operands too when no `>` closes the list", + "start": 1576, + "end": 1656 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 1680, + "end": 1700, + "loc": { + "start": { + "line": 51, + "column": 1 + }, + "end": { + "line": 51, + "column": 21 + } + }, + "expression": { + "type": "CallExpression", + "start": 1680, + "end": 1699, + "loc": { + "start": { + "line": 51, + "column": 1 + }, + "end": { + "line": 51, + "column": 20 + } + }, + "callee": { + "type": "Identifier", + "start": 1680, + "end": 1682, + "loc": { + "start": { + "line": 51, + "column": 1 + }, + "end": { + "line": 51, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1683, + "end": 1695, + "loc": { + "start": { + "line": 51, + "column": 4 + }, + "end": { + "line": 51, + "column": 16 + } + }, + "left": { + "type": "Identifier", + "start": 1683, + "end": 1684, + "loc": { + "start": { + "line": 51, + "column": 4 + }, + "end": { + "line": 51, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1687, + "end": 1695, + "loc": { + "start": { + "line": 51, + "column": 8 + }, + "end": { + "line": 51, + "column": 16 + } + }, + "object": { + "type": "Identifier", + "start": 1687, + "end": 1688, + "loc": { + "start": { + "line": 51, + "column": 8 + }, + "end": { + "line": 51, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "BinaryExpression", + "start": 1689, + "end": 1694, + "loc": { + "start": { + "line": 51, + "column": 10 + }, + "end": { + "line": 51, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 1689, + "end": 1690, + "loc": { + "start": { + "line": 51, + "column": 10 + }, + "end": { + "line": 51, + "column": 11 + } + }, + "name": "c" + }, + "operator": "&", + "right": { + "type": "Identifier", + "start": 1693, + "end": 1694, + "loc": { + "start": { + "line": 51, + "column": 14 + }, + "end": { + "line": 51, + "column": 15 + } + }, + "name": "d" + } + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1697, + "end": 1698, + "loc": { + "start": { + "line": 51, + "column": 18 + }, + "end": { + "line": 51, + "column": 19 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1702, + "end": 1721, + "loc": { + "start": { + "line": 52, + "column": 1 + }, + "end": { + "line": 52, + "column": 20 + } + }, + "expression": { + "type": "CallExpression", + "start": 1702, + "end": 1720, + "loc": { + "start": { + "line": 52, + "column": 1 + }, + "end": { + "line": 52, + "column": 19 + } + }, + "callee": { + "type": "Identifier", + "start": 1702, + "end": 1704, + "loc": { + "start": { + "line": 52, + "column": 1 + }, + "end": { + "line": 52, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1705, + "end": 1716, + "loc": { + "start": { + "line": 52, + "column": 4 + }, + "end": { + "line": 52, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 1705, + "end": 1706, + "loc": { + "start": { + "line": 52, + "column": 4 + }, + "end": { + "line": 52, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1709, + "end": 1716, + "loc": { + "start": { + "line": 52, + "column": 8 + }, + "end": { + "line": 52, + "column": 15 + } + }, + "object": { + "type": "Identifier", + "start": 1709, + "end": 1710, + "loc": { + "start": { + "line": 52, + "column": 8 + }, + "end": { + "line": 52, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "MemberExpression", + "start": 1711, + "end": 1715, + "loc": { + "start": { + "line": 52, + "column": 10 + }, + "end": { + "line": 52, + "column": 14 + } + }, + "object": { + "type": "Identifier", + "start": 1711, + "end": 1712, + "loc": { + "start": { + "line": 52, + "column": 10 + }, + "end": { + "line": 52, + "column": 11 + } + }, + "name": "c" + }, + "property": { + "type": "Identifier", + "start": 1713, + "end": 1714, + "loc": { + "start": { + "line": 52, + "column": 12 + }, + "end": { + "line": 52, + "column": 13 + } + }, + "name": "d" + }, + "computed": true, + "optional": false + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1718, + "end": 1719, + "loc": { + "start": { + "line": 52, + "column": 17 + }, + "end": { + "line": 52, + "column": 18 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1723, + "end": 1739, + "loc": { + "start": { + "line": 53, + "column": 1 + }, + "end": { + "line": 53, + "column": 17 + } + }, + "expression": { + "type": "CallExpression", + "start": 1723, + "end": 1738, + "loc": { + "start": { + "line": 53, + "column": 1 + }, + "end": { + "line": 53, + "column": 16 + } + }, + "callee": { + "type": "Identifier", + "start": 1723, + "end": 1725, + "loc": { + "start": { + "line": 53, + "column": 1 + }, + "end": { + "line": 53, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1726, + "end": 1734, + "loc": { + "start": { + "line": 53, + "column": 4 + }, + "end": { + "line": 53, + "column": 12 + } + }, + "left": { + "type": "Identifier", + "start": 1726, + "end": 1727, + "loc": { + "start": { + "line": 53, + "column": 4 + }, + "end": { + "line": 53, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1730, + "end": 1734, + "loc": { + "start": { + "line": 53, + "column": 8 + }, + "end": { + "line": 53, + "column": 12 + } + }, + "object": { + "type": "Identifier", + "start": 1730, + "end": 1731, + "loc": { + "start": { + "line": 53, + "column": 8 + }, + "end": { + "line": 53, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "Literal", + "start": 1732, + "end": 1733, + "loc": { + "start": { + "line": 53, + "column": 10 + }, + "end": { + "line": 53, + "column": 11 + } + }, + "value": 0, + "raw": "0" + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1736, + "end": 1737, + "loc": { + "start": { + "line": 53, + "column": 14 + }, + "end": { + "line": 53, + "column": 15 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1741, + "end": 1758, + "loc": { + "start": { + "line": 54, + "column": 1 + }, + "end": { + "line": 54, + "column": 18 + } + }, + "expression": { + "type": "CallExpression", + "start": 1741, + "end": 1757, + "loc": { + "start": { + "line": 54, + "column": 1 + }, + "end": { + "line": 54, + "column": 17 + } + }, + "callee": { + "type": "Identifier", + "start": 1741, + "end": 1743, + "loc": { + "start": { + "line": 54, + "column": 1 + }, + "end": { + "line": 54, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1744, + "end": 1753, + "loc": { + "start": { + "line": 54, + "column": 4 + }, + "end": { + "line": 54, + "column": 13 + } + }, + "left": { + "type": "Identifier", + "start": 1744, + "end": 1745, + "loc": { + "start": { + "line": 54, + "column": 4 + }, + "end": { + "line": 54, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1748, + "end": 1753, + "loc": { + "start": { + "line": 54, + "column": 8 + }, + "end": { + "line": 54, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 1748, + "end": 1749, + "loc": { + "start": { + "line": 54, + "column": 8 + }, + "end": { + "line": 54, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "UnaryExpression", + "start": 1750, + "end": 1752, + "loc": { + "start": { + "line": 54, + "column": 10 + }, + "end": { + "line": 54, + "column": 12 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 1751, + "end": 1752, + "loc": { + "start": { + "line": 54, + "column": 11 + }, + "end": { + "line": 54, + "column": 12 + } + }, + "value": 1, + "raw": "1" + } + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1755, + "end": 1756, + "loc": { + "start": { + "line": 54, + "column": 15 + }, + "end": { + "line": 54, + "column": 16 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1760, + "end": 1778, + "loc": { + "start": { + "line": 55, + "column": 1 + }, + "end": { + "line": 55, + "column": 19 + } + }, + "expression": { + "type": "CallExpression", + "start": 1760, + "end": 1777, + "loc": { + "start": { + "line": 55, + "column": 1 + }, + "end": { + "line": 55, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 1760, + "end": 1762, + "loc": { + "start": { + "line": 55, + "column": 1 + }, + "end": { + "line": 55, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1763, + "end": 1773, + "loc": { + "start": { + "line": 55, + "column": 4 + }, + "end": { + "line": 55, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 1763, + "end": 1764, + "loc": { + "start": { + "line": 55, + "column": 4 + }, + "end": { + "line": 55, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1767, + "end": 1773, + "loc": { + "start": { + "line": 55, + "column": 8 + }, + "end": { + "line": 55, + "column": 14 + } + }, + "object": { + "type": "Identifier", + "start": 1767, + "end": 1768, + "loc": { + "start": { + "line": 55, + "column": 8 + }, + "end": { + "line": 55, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "MemberExpression", + "start": 1769, + "end": 1772, + "loc": { + "start": { + "line": 55, + "column": 10 + }, + "end": { + "line": 55, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 1769, + "end": 1770, + "loc": { + "start": { + "line": 55, + "column": 10 + }, + "end": { + "line": 55, + "column": 11 + } + }, + "name": "c" + }, + "property": { + "type": "Identifier", + "start": 1771, + "end": 1772, + "loc": { + "start": { + "line": 55, + "column": 12 + }, + "end": { + "line": 55, + "column": 13 + } + }, + "name": "d" + }, + "computed": false, + "optional": false + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1775, + "end": 1776, + "loc": { + "start": { + "line": 55, + "column": 16 + }, + "end": { + "line": 55, + "column": 17 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1780, + "end": 1801, + "loc": { + "start": { + "line": 56, + "column": 1 + }, + "end": { + "line": 56, + "column": 22 + } + }, + "expression": { + "type": "CallExpression", + "start": 1780, + "end": 1800, + "loc": { + "start": { + "line": 56, + "column": 1 + }, + "end": { + "line": 56, + "column": 21 + } + }, + "callee": { + "type": "Identifier", + "start": 1780, + "end": 1782, + "loc": { + "start": { + "line": 56, + "column": 1 + }, + "end": { + "line": 56, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1783, + "end": 1796, + "loc": { + "start": { + "line": 56, + "column": 4 + }, + "end": { + "line": 56, + "column": 17 + } + }, + "left": { + "type": "Identifier", + "start": 1783, + "end": 1784, + "loc": { + "start": { + "line": 56, + "column": 4 + }, + "end": { + "line": 56, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1787, + "end": 1796, + "loc": { + "start": { + "line": 56, + "column": 8 + }, + "end": { + "line": 56, + "column": 17 + } + }, + "object": { + "type": "Identifier", + "start": 1787, + "end": 1788, + "loc": { + "start": { + "line": 56, + "column": 8 + }, + "end": { + "line": 56, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "MemberExpression", + "start": 1789, + "end": 1795, + "loc": { + "start": { + "line": 56, + "column": 10 + }, + "end": { + "line": 56, + "column": 16 + } + }, + "object": { + "type": "Identifier", + "start": 1789, + "end": 1790, + "loc": { + "start": { + "line": 56, + "column": 10 + }, + "end": { + "line": 56, + "column": 11 + } + }, + "name": "c" + }, + "property": { + "type": "Literal", + "start": 1791, + "end": 1794, + "loc": { + "start": { + "line": 56, + "column": 12 + }, + "end": { + "line": 56, + "column": 15 + } + }, + "value": "k", + "raw": "'k'" + }, + "computed": true, + "optional": false + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1798, + "end": 1799, + "loc": { + "start": { + "line": 56, + "column": 19 + }, + "end": { + "line": 56, + "column": 20 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "ExpressionStatement", + "start": 1803, + "end": 1823, + "loc": { + "start": { + "line": 57, + "column": 1 + }, + "end": { + "line": 57, + "column": 21 + } + }, + "expression": { + "type": "CallExpression", + "start": 1803, + "end": 1822, + "loc": { + "start": { + "line": 57, + "column": 1 + }, + "end": { + "line": 57, + "column": 20 + } + }, + "callee": { + "type": "Identifier", + "start": 1803, + "end": 1805, + "loc": { + "start": { + "line": 57, + "column": 1 + }, + "end": { + "line": 57, + "column": 3 + } + }, + "name": "fn" + }, + "arguments": [ + { + "type": "BinaryExpression", + "start": 1806, + "end": 1818, + "loc": { + "start": { + "line": 57, + "column": 4 + }, + "end": { + "line": 57, + "column": 16 + } + }, + "left": { + "type": "Identifier", + "start": 1806, + "end": 1807, + "loc": { + "start": { + "line": 57, + "column": 4 + }, + "end": { + "line": 57, + "column": 5 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 1810, + "end": 1818, + "loc": { + "start": { + "line": 57, + "column": 8 + }, + "end": { + "line": 57, + "column": 16 + } + }, + "object": { + "type": "Identifier", + "start": 1810, + "end": 1811, + "loc": { + "start": { + "line": 57, + "column": 8 + }, + "end": { + "line": 57, + "column": 9 + } + }, + "name": "B" + }, + "property": { + "type": "BinaryExpression", + "start": 1812, + "end": 1817, + "loc": { + "start": { + "line": 57, + "column": 10 + }, + "end": { + "line": 57, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 1812, + "end": 1813, + "loc": { + "start": { + "line": 57, + "column": 10 + }, + "end": { + "line": 57, + "column": 11 + } + }, + "name": "c" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 1816, + "end": 1817, + "loc": { + "start": { + "line": 57, + "column": 14 + }, + "end": { + "line": 57, + "column": 15 + } + }, + "name": "d" + } + }, + "computed": true, + "optional": false + } + }, + { + "type": "Identifier", + "start": 1820, + "end": 1821, + "loc": { + "start": { + "line": 57, + "column": 18 + }, + "end": { + "line": 57, + "column": 19 + } + }, + "name": "e" + } + ], + "optional": false + } + }, + { + "type": "VariableDeclaration", + "start": 2031, + "end": 2062, + "loc": { + "start": { + "line": 62, + "column": 1 + }, + "end": { + "line": 62, + "column": 32 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2037, + "end": 2061, + "loc": { + "start": { + "line": 62, + "column": 7 + }, + "end": { + "line": 62, + "column": 31 + } + }, + "id": { + "type": "Identifier", + "start": 2037, + "end": 2040, + "loc": { + "start": { + "line": 62, + "column": 7 + }, + "end": { + "line": 62, + "column": 10 + } + }, + "name": "a32" + }, + "init": { + "type": "BinaryExpression", + "start": 2043, + "end": 2061, + "loc": { + "start": { + "line": 62, + "column": 13 + }, + "end": { + "line": 62, + "column": 31 + } + }, + "left": { + "type": "BinaryExpression", + "start": 2043, + "end": 2057, + "loc": { + "start": { + "line": 62, + "column": 13 + }, + "end": { + "line": 62, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 2043, + "end": 2044, + "loc": { + "start": { + "line": 62, + "column": 13 + }, + "end": { + "line": 62, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 2047, + "end": 2057, + "loc": { + "start": { + "line": 62, + "column": 17 + }, + "end": { + "line": 62, + "column": 27 + } + }, + "object": { + "type": "Identifier", + "start": 2047, + "end": 2050, + "loc": { + "start": { + "line": 62, + "column": 17 + }, + "end": { + "line": 62, + "column": 20 + } + }, + "name": "arr" + }, + "property": { + "type": "BinaryExpression", + "start": 2051, + "end": 2056, + "loc": { + "start": { + "line": 62, + "column": 21 + }, + "end": { + "line": 62, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 2051, + "end": 2052, + "loc": { + "start": { + "line": 62, + "column": 21 + }, + "end": { + "line": 62, + "column": 22 + } + }, + "name": "b" + }, + "operator": "-", + "right": { + "type": "Literal", + "start": 2055, + "end": 2056, + "loc": { + "start": { + "line": 62, + "column": 25 + }, + "end": { + "line": 62, + "column": 26 + } + }, + "value": 1, + "raw": "1" + } + }, + "computed": true, + "optional": false + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 2060, + "end": 2061, + "loc": { + "start": { + "line": 62, + "column": 30 + }, + "end": { + "line": 62, + "column": 31 + } + }, + "name": "c" + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " arithmetic inside the index is not a type, so the list stays a comparison even", + "start": 1826, + "end": 1907 + }, + { + "type": "Line", + "value": " when a `>` closes it; a negated operand and the logical and relational operators", + "start": 1909, + "end": 1992 + }, + { + "type": "Line", + "value": " are expressions too, never types", + "start": 1994, + "end": 2029 + } + ] + }, + { + "type": "VariableDeclaration", + "start": 2064, + "end": 2092, + "loc": { + "start": { + "line": 63, + "column": 1 + }, + "end": { + "line": 63, + "column": 29 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2070, + "end": 2091, + "loc": { + "start": { + "line": 63, + "column": 7 + }, + "end": { + "line": 63, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 2070, + "end": 2073, + "loc": { + "start": { + "line": 63, + "column": 7 + }, + "end": { + "line": 63, + "column": 10 + } + }, + "name": "a33" + }, + "init": { + "type": "BinaryExpression", + "start": 2076, + "end": 2091, + "loc": { + "start": { + "line": 63, + "column": 13 + }, + "end": { + "line": 63, + "column": 28 + } + }, + "left": { + "type": "BinaryExpression", + "start": 2076, + "end": 2087, + "loc": { + "start": { + "line": 63, + "column": 13 + }, + "end": { + "line": 63, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 2076, + "end": 2077, + "loc": { + "start": { + "line": 63, + "column": 13 + }, + "end": { + "line": 63, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 2080, + "end": 2087, + "loc": { + "start": { + "line": 63, + "column": 17 + }, + "end": { + "line": 63, + "column": 24 + } + }, + "object": { + "type": "Identifier", + "start": 2080, + "end": 2083, + "loc": { + "start": { + "line": 63, + "column": 17 + }, + "end": { + "line": 63, + "column": 20 + } + }, + "name": "arr" + }, + "property": { + "type": "UnaryExpression", + "start": 2084, + "end": 2086, + "loc": { + "start": { + "line": 63, + "column": 21 + }, + "end": { + "line": 63, + "column": 23 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 2085, + "end": 2086, + "loc": { + "start": { + "line": 63, + "column": 22 + }, + "end": { + "line": 63, + "column": 23 + } + }, + "name": "b" + } + }, + "computed": true, + "optional": false + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 2090, + "end": 2091, + "loc": { + "start": { + "line": 63, + "column": 27 + }, + "end": { + "line": 63, + "column": 28 + } + }, + "name": "c" + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2094, + "end": 2124, + "loc": { + "start": { + "line": 64, + "column": 1 + }, + "end": { + "line": 64, + "column": 31 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2100, + "end": 2123, + "loc": { + "start": { + "line": 64, + "column": 7 + }, + "end": { + "line": 64, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 2100, + "end": 2103, + "loc": { + "start": { + "line": 64, + "column": 7 + }, + "end": { + "line": 64, + "column": 10 + } + }, + "name": "a34" + }, + "init": { + "type": "BinaryExpression", + "start": 2106, + "end": 2123, + "loc": { + "start": { + "line": 64, + "column": 13 + }, + "end": { + "line": 64, + "column": 30 + } + }, + "left": { + "type": "BinaryExpression", + "start": 2106, + "end": 2119, + "loc": { + "start": { + "line": 64, + "column": 13 + }, + "end": { + "line": 64, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 2106, + "end": 2107, + "loc": { + "start": { + "line": 64, + "column": 13 + }, + "end": { + "line": 64, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 2110, + "end": 2119, + "loc": { + "start": { + "line": 64, + "column": 17 + }, + "end": { + "line": 64, + "column": 26 + } + }, + "object": { + "type": "Identifier", + "start": 2110, + "end": 2111, + "loc": { + "start": { + "line": 64, + "column": 17 + }, + "end": { + "line": 64, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "LogicalExpression", + "start": 2112, + "end": 2118, + "loc": { + "start": { + "line": 64, + "column": 19 + }, + "end": { + "line": 64, + "column": 25 + } + }, + "left": { + "type": "Literal", + "start": 2112, + "end": 2113, + "loc": { + "start": { + "line": 64, + "column": 19 + }, + "end": { + "line": 64, + "column": 20 + } + }, + "value": 0, + "raw": "0" + }, + "operator": "||", + "right": { + "type": "Literal", + "start": 2117, + "end": 2118, + "loc": { + "start": { + "line": 64, + "column": 24 + }, + "end": { + "line": 64, + "column": 25 + } + }, + "value": 1, + "raw": "1" + } + }, + "computed": true, + "optional": false + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 2122, + "end": 2123, + "loc": { + "start": { + "line": 64, + "column": 29 + }, + "end": { + "line": 64, + "column": 30 + } + }, + "name": "c" + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2126, + "end": 2156, + "loc": { + "start": { + "line": 65, + "column": 1 + }, + "end": { + "line": 65, + "column": 31 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2132, + "end": 2155, + "loc": { + "start": { + "line": 65, + "column": 7 + }, + "end": { + "line": 65, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 2132, + "end": 2135, + "loc": { + "start": { + "line": 65, + "column": 7 + }, + "end": { + "line": 65, + "column": 10 + } + }, + "name": "a35" + }, + "init": { + "type": "BinaryExpression", + "start": 2138, + "end": 2155, + "loc": { + "start": { + "line": 65, + "column": 13 + }, + "end": { + "line": 65, + "column": 30 + } + }, + "left": { + "type": "BinaryExpression", + "start": 2138, + "end": 2151, + "loc": { + "start": { + "line": 65, + "column": 13 + }, + "end": { + "line": 65, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 2138, + "end": 2139, + "loc": { + "start": { + "line": 65, + "column": 13 + }, + "end": { + "line": 65, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 2142, + "end": 2151, + "loc": { + "start": { + "line": 65, + "column": 17 + }, + "end": { + "line": 65, + "column": 26 + } + }, + "object": { + "type": "Identifier", + "start": 2142, + "end": 2143, + "loc": { + "start": { + "line": 65, + "column": 17 + }, + "end": { + "line": 65, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "BinaryExpression", + "start": 2144, + "end": 2150, + "loc": { + "start": { + "line": 65, + "column": 19 + }, + "end": { + "line": 65, + "column": 25 + } + }, + "left": { + "type": "Literal", + "start": 2144, + "end": 2145, + "loc": { + "start": { + "line": 65, + "column": 19 + }, + "end": { + "line": 65, + "column": 20 + } + }, + "value": 0, + "raw": "0" + }, + "operator": "<=", + "right": { + "type": "Literal", + "start": 2149, + "end": 2150, + "loc": { + "start": { + "line": 65, + "column": 24 + }, + "end": { + "line": 65, + "column": 25 + } + }, + "value": 1, + "raw": "1" + } + }, + "computed": true, + "optional": false + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 2154, + "end": 2155, + "loc": { + "start": { + "line": 65, + "column": 29 + }, + "end": { + "line": 65, + "column": 30 + } + }, + "name": "c" + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2318, + "end": 2343, + "loc": { + "start": { + "line": 69, + "column": 1 + }, + "end": { + "line": 69, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2324, + "end": 2342, + "loc": { + "start": { + "line": 69, + "column": 7 + }, + "end": { + "line": 69, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 2324, + "end": 2327, + "loc": { + "start": { + "line": 69, + "column": 7 + }, + "end": { + "line": 69, + "column": 10 + } + }, + "name": "a28" + }, + "init": { + "type": "BinaryExpression", + "start": 2330, + "end": 2342, + "loc": { + "start": { + "line": 69, + "column": 13 + }, + "end": { + "line": 69, + "column": 25 + } + }, + "left": { + "type": "BinaryExpression", + "start": 2330, + "end": 2338, + "loc": { + "start": { + "line": 69, + "column": 13 + }, + "end": { + "line": 69, + "column": 21 + } + }, + "left": { + "type": "Identifier", + "start": 2330, + "end": 2331, + "loc": { + "start": { + "line": 69, + "column": 13 + }, + "end": { + "line": 69, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "MemberExpression", + "start": 2334, + "end": 2338, + "loc": { + "start": { + "line": 69, + "column": 17 + }, + "end": { + "line": 69, + "column": 21 + } + }, + "object": { + "type": "Identifier", + "start": 2334, + "end": 2335, + "loc": { + "start": { + "line": 69, + "column": 17 + }, + "end": { + "line": 69, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 2336, + "end": 2337, + "loc": { + "start": { + "line": 69, + "column": 19 + }, + "end": { + "line": 69, + "column": 20 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 2341, + "end": 2342, + "loc": { + "start": { + "line": 69, + "column": 24 + }, + "end": { + "line": 69, + "column": 25 + } + }, + "name": "d" + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " a `>` or a shift operator after the indexed operand continues the comparison", + "start": 2159, + "end": 2238 + }, + { + "type": "Line", + "value": " chain — the `>` run belongs to the operator, not to a type-argument close", + "start": 2240, + "end": 2316 + } + ] + }, + { + "type": "VariableDeclaration", + "start": 2345, + "end": 2371, + "loc": { + "start": { + "line": 70, + "column": 1 + }, + "end": { + "line": 70, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2351, + "end": 2370, + "loc": { + "start": { + "line": 70, + "column": 7 + }, + "end": { + "line": 70, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 2351, + "end": 2354, + "loc": { + "start": { + "line": 70, + "column": 7 + }, + "end": { + "line": 70, + "column": 10 + } + }, + "name": "a29" + }, + "init": { + "type": "BinaryExpression", + "start": 2357, + "end": 2370, + "loc": { + "start": { + "line": 70, + "column": 13 + }, + "end": { + "line": 70, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 2357, + "end": 2358, + "loc": { + "start": { + "line": 70, + "column": 13 + }, + "end": { + "line": 70, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "BinaryExpression", + "start": 2361, + "end": 2370, + "loc": { + "start": { + "line": 70, + "column": 17 + }, + "end": { + "line": 70, + "column": 26 + } + }, + "left": { + "type": "MemberExpression", + "start": 2361, + "end": 2365, + "loc": { + "start": { + "line": 70, + "column": 17 + }, + "end": { + "line": 70, + "column": 21 + } + }, + "object": { + "type": "Identifier", + "start": 2361, + "end": 2362, + "loc": { + "start": { + "line": 70, + "column": 17 + }, + "end": { + "line": 70, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 2363, + "end": 2364, + "loc": { + "start": { + "line": 70, + "column": 19 + }, + "end": { + "line": 70, + "column": 20 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + }, + "operator": ">>", + "right": { + "type": "Identifier", + "start": 2369, + "end": 2370, + "loc": { + "start": { + "line": 70, + "column": 25 + }, + "end": { + "line": 70, + "column": 26 + } + }, + "name": "d" + } + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2373, + "end": 2400, + "loc": { + "start": { + "line": 71, + "column": 1 + }, + "end": { + "line": 71, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2379, + "end": 2399, + "loc": { + "start": { + "line": 71, + "column": 7 + }, + "end": { + "line": 71, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 2379, + "end": 2382, + "loc": { + "start": { + "line": 71, + "column": 7 + }, + "end": { + "line": 71, + "column": 10 + } + }, + "name": "a30" + }, + "init": { + "type": "BinaryExpression", + "start": 2385, + "end": 2399, + "loc": { + "start": { + "line": 71, + "column": 13 + }, + "end": { + "line": 71, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 2385, + "end": 2386, + "loc": { + "start": { + "line": 71, + "column": 13 + }, + "end": { + "line": 71, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "BinaryExpression", + "start": 2389, + "end": 2399, + "loc": { + "start": { + "line": 71, + "column": 17 + }, + "end": { + "line": 71, + "column": 27 + } + }, + "left": { + "type": "MemberExpression", + "start": 2389, + "end": 2393, + "loc": { + "start": { + "line": 71, + "column": 17 + }, + "end": { + "line": 71, + "column": 21 + } + }, + "object": { + "type": "Identifier", + "start": 2389, + "end": 2390, + "loc": { + "start": { + "line": 71, + "column": 17 + }, + "end": { + "line": 71, + "column": 18 + } + }, + "name": "B" + }, + "property": { + "type": "Identifier", + "start": 2391, + "end": 2392, + "loc": { + "start": { + "line": 71, + "column": 19 + }, + "end": { + "line": 71, + "column": 20 + } + }, + "name": "c" + }, + "computed": true, + "optional": false + }, + "operator": ">>>", + "right": { + "type": "Identifier", + "start": 2398, + "end": 2399, + "loc": { + "start": { + "line": 71, + "column": 26 + }, + "end": { + "line": 71, + "column": 27 + } + }, + "name": "d" + } + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2526, + "end": 2544, + "loc": { + "start": { + "line": 75, + "column": 1 + }, + "end": { + "line": 75, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2532, + "end": 2543, + "loc": { + "start": { + "line": 75, + "column": 7 + }, + "end": { + "line": 75, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 2532, + "end": 2535, + "loc": { + "start": { + "line": 75, + "column": 7 + }, + "end": { + "line": 75, + "column": 10 + } + }, + "name": "a31" + }, + "init": { + "type": "BinaryExpression", + "start": 2538, + "end": 2543, + "loc": { + "start": { + "line": 75, + "column": 13 + }, + "end": { + "line": 75, + "column": 18 + } + }, + "left": { + "type": "Identifier", + "start": 2538, + "end": 2539, + "loc": { + "start": { + "line": 75, + "column": 13 + }, + "end": { + "line": 75, + "column": 14 + } + }, + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 2542, + "end": 2543, + "loc": { + "start": { + "line": 75, + "column": 17 + }, + "end": { + "line": 75, + "column": 18 + } + }, + "name": "b" + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " an identifier that merely starts with `extends` is a fresh statement on the next", + "start": 2403, + "end": 2486 + }, + { + "type": "Line", + "value": " line (ASI), not a type constraint", + "start": 2488, + "end": 2524 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 2546, + "end": 2559, + "loc": { + "start": { + "line": 76, + "column": 1 + }, + "end": { + "line": 76, + "column": 14 + } + }, + "expression": { + "type": "CallExpression", + "start": 2546, + "end": 2558, + "loc": { + "start": { + "line": 76, + "column": 1 + }, + "end": { + "line": 76, + "column": 13 + } + }, + "callee": { + "type": "Identifier", + "start": 2546, + "end": 2556, + "loc": { + "start": { + "line": 76, + "column": 1 + }, + "end": { + "line": 76, + "column": 11 + } + }, + "name": "extendsFoo" + }, + "arguments": [], + "optional": false + } + }, + { + "type": "VariableDeclaration", + "start": 2720, + "end": 2741, + "loc": { + "start": { + "line": 80, + "column": 1 + }, + "end": { + "line": 80, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2726, + "end": 2740, + "loc": { + "start": { + "line": 80, + "column": 7 + }, + "end": { + "line": 80, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 2726, + "end": 2728, + "loc": { + "start": { + "line": 80, + "column": 7 + }, + "end": { + "line": 80, + "column": 9 + } + }, + "name": "b1" + }, + "init": { + "type": "CallExpression", + "start": 2731, + "end": 2740, + "loc": { + "start": { + "line": 80, + "column": 12 + }, + "end": { + "line": 80, + "column": 21 + } + }, + "callee": { + "type": "Identifier", + "start": 2731, + "end": 2733, + "loc": { + "start": { + "line": 80, + "column": 12 + }, + "end": { + "line": 80, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2733, + "end": 2738, + "loc": { + "start": { + "line": 80, + "column": 14 + }, + "end": { + "line": 80, + "column": 19 + } + }, + "params": [ + { + "type": "TSLiteralType", + "start": 2734, + "end": 2737, + "loc": { + "start": { + "line": 80, + "column": 15 + }, + "end": { + "line": 80, + "column": 18 + } + }, + "literal": { + "type": "Literal", + "start": 2734, + "end": 2737, + "loc": { + "start": { + "line": 80, + "column": 15 + }, + "end": { + "line": 80, + "column": 18 + } + }, + "value": "b", + "raw": "'b'" + } + } + ] + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " genuine instantiation with a literal/keyword/object/tuple/numeric type arg, or a", + "start": 2562, + "end": 2645 + }, + { + "type": "Line", + "value": " function type with an optional param, still parses as type arguments", + "start": 2647, + "end": 2718 + } + ] + }, + { + "type": "VariableDeclaration", + "start": 2743, + "end": 2765, + "loc": { + "start": { + "line": 81, + "column": 1 + }, + "end": { + "line": 81, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2749, + "end": 2764, + "loc": { + "start": { + "line": 81, + "column": 7 + }, + "end": { + "line": 81, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 2749, + "end": 2751, + "loc": { + "start": { + "line": 81, + "column": 7 + }, + "end": { + "line": 81, + "column": 9 + } + }, + "name": "b2" + }, + "init": { + "type": "CallExpression", + "start": 2754, + "end": 2764, + "loc": { + "start": { + "line": 81, + "column": 12 + }, + "end": { + "line": 81, + "column": 22 + } + }, + "callee": { + "type": "Identifier", + "start": 2754, + "end": 2756, + "loc": { + "start": { + "line": 81, + "column": 12 + }, + "end": { + "line": 81, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2756, + "end": 2762, + "loc": { + "start": { + "line": 81, + "column": 14 + }, + "end": { + "line": 81, + "column": 20 + } + }, + "params": [ + { + "type": "TSLiteralType", + "start": 2757, + "end": 2761, + "loc": { + "start": { + "line": 81, + "column": 15 + }, + "end": { + "line": 81, + "column": 19 + } + }, + "literal": { + "type": "Literal", + "start": 2757, + "end": 2761, + "loc": { + "start": { + "line": 81, + "column": 15 + }, + "end": { + "line": 81, + "column": 19 + } + }, + "value": true, + "raw": "true" + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2767, + "end": 2791, + "loc": { + "start": { + "line": 82, + "column": 1 + }, + "end": { + "line": 82, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2773, + "end": 2790, + "loc": { + "start": { + "line": 82, + "column": 7 + }, + "end": { + "line": 82, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 2773, + "end": 2775, + "loc": { + "start": { + "line": 82, + "column": 7 + }, + "end": { + "line": 82, + "column": 9 + } + }, + "name": "b3" + }, + "init": { + "type": "CallExpression", + "start": 2778, + "end": 2790, + "loc": { + "start": { + "line": 82, + "column": 12 + }, + "end": { + "line": 82, + "column": 24 + } + }, + "callee": { + "type": "Identifier", + "start": 2778, + "end": 2780, + "loc": { + "start": { + "line": 82, + "column": 12 + }, + "end": { + "line": 82, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2780, + "end": 2788, + "loc": { + "start": { + "line": 82, + "column": 14 + }, + "end": { + "line": 82, + "column": 22 + } + }, + "params": [ + { + "type": "TSStringKeyword", + "start": 2781, + "end": 2787, + "loc": { + "start": { + "line": 82, + "column": 15 + }, + "end": { + "line": 82, + "column": 21 + } + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2793, + "end": 2824, + "loc": { + "start": { + "line": 83, + "column": 1 + }, + "end": { + "line": 83, + "column": 32 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2799, + "end": 2823, + "loc": { + "start": { + "line": 83, + "column": 7 + }, + "end": { + "line": 83, + "column": 31 + } + }, + "id": { + "type": "Identifier", + "start": 2799, + "end": 2801, + "loc": { + "start": { + "line": 83, + "column": 7 + }, + "end": { + "line": 83, + "column": 9 + } + }, + "name": "b4" + }, + "init": { + "type": "CallExpression", + "start": 2804, + "end": 2823, + "loc": { + "start": { + "line": 83, + "column": 12 + }, + "end": { + "line": 83, + "column": 31 + } + }, + "callee": { + "type": "Identifier", + "start": 2804, + "end": 2806, + "loc": { + "start": { + "line": 83, + "column": 12 + }, + "end": { + "line": 83, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2806, + "end": 2821, + "loc": { + "start": { + "line": 83, + "column": 14 + }, + "end": { + "line": 83, + "column": 29 + } + }, + "params": [ + { + "type": "TSTypeLiteral", + "start": 2807, + "end": 2820, + "loc": { + "start": { + "line": 83, + "column": 15 + }, + "end": { + "line": 83, + "column": 28 + } + }, + "members": [ + { + "type": "TSPropertySignature", + "start": 2809, + "end": 2818, + "loc": { + "start": { + "line": 83, + "column": 17 + }, + "end": { + "line": 83, + "column": 26 + } + }, + "computed": false, + "key": { + "type": "Identifier", + "start": 2809, + "end": 2810, + "loc": { + "start": { + "line": 83, + "column": 17 + }, + "end": { + "line": 83, + "column": 18 + } + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 2810, + "end": 2818, + "loc": { + "start": { + "line": 83, + "column": 18 + }, + "end": { + "line": 83, + "column": 26 + } + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 2812, + "end": 2818, + "loc": { + "start": { + "line": 83, + "column": 20 + }, + "end": { + "line": 83, + "column": 26 + } + } + } + } + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2826, + "end": 2850, + "loc": { + "start": { + "line": 84, + "column": 1 + }, + "end": { + "line": 84, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2832, + "end": 2849, + "loc": { + "start": { + "line": 84, + "column": 7 + }, + "end": { + "line": 84, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 2832, + "end": 2834, + "loc": { + "start": { + "line": 84, + "column": 7 + }, + "end": { + "line": 84, + "column": 9 + } + }, + "name": "b5" + }, + "init": { + "type": "CallExpression", + "start": 2837, + "end": 2849, + "loc": { + "start": { + "line": 84, + "column": 12 + }, + "end": { + "line": 84, + "column": 24 + } + }, + "callee": { + "type": "Identifier", + "start": 2837, + "end": 2839, + "loc": { + "start": { + "line": 84, + "column": 12 + }, + "end": { + "line": 84, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2839, + "end": 2847, + "loc": { + "start": { + "line": 84, + "column": 14 + }, + "end": { + "line": 84, + "column": 22 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 2840, + "end": 2846, + "loc": { + "start": { + "line": 84, + "column": 15 + }, + "end": { + "line": 84, + "column": 21 + } + }, + "elementTypes": [ + { + "type": "TSTypeReference", + "start": 2841, + "end": 2842, + "loc": { + "start": { + "line": 84, + "column": 16 + }, + "end": { + "line": 84, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 2841, + "end": 2842, + "loc": { + "start": { + "line": 84, + "column": 16 + }, + "end": { + "line": 84, + "column": 17 + } + }, + "name": "A" + } + }, + { + "type": "TSTypeReference", + "start": 2844, + "end": 2845, + "loc": { + "start": { + "line": 84, + "column": 19 + }, + "end": { + "line": 84, + "column": 20 + } + }, + "typeName": { + "type": "Identifier", + "start": 2844, + "end": 2845, + "loc": { + "start": { + "line": 84, + "column": 19 + }, + "end": { + "line": 84, + "column": 20 + } + }, + "name": "B" + } + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2852, + "end": 2871, + "loc": { + "start": { + "line": 85, + "column": 1 + }, + "end": { + "line": 85, + "column": 20 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2858, + "end": 2870, + "loc": { + "start": { + "line": 85, + "column": 7 + }, + "end": { + "line": 85, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 2858, + "end": 2860, + "loc": { + "start": { + "line": 85, + "column": 7 + }, + "end": { + "line": 85, + "column": 9 + } + }, + "name": "b6" + }, + "init": { + "type": "CallExpression", + "start": 2863, + "end": 2870, + "loc": { + "start": { + "line": 85, + "column": 12 + }, + "end": { + "line": 85, + "column": 19 + } + }, + "callee": { + "type": "Identifier", + "start": 2863, + "end": 2865, + "loc": { + "start": { + "line": 85, + "column": 12 + }, + "end": { + "line": 85, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2865, + "end": 2868, + "loc": { + "start": { + "line": 85, + "column": 14 + }, + "end": { + "line": 85, + "column": 17 + } + }, + "params": [ + { + "type": "TSLiteralType", + "start": 2866, + "end": 2867, + "loc": { + "start": { + "line": 85, + "column": 15 + }, + "end": { + "line": 85, + "column": 16 + } + }, + "literal": { + "type": "Literal", + "start": 2866, + "end": 2867, + "loc": { + "start": { + "line": 85, + "column": 15 + }, + "end": { + "line": 85, + "column": 16 + } + }, + "value": 1, + "raw": "1" + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2873, + "end": 2903, + "loc": { + "start": { + "line": 86, + "column": 1 + }, + "end": { + "line": 86, + "column": 31 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2879, + "end": 2902, + "loc": { + "start": { + "line": 86, + "column": 7 + }, + "end": { + "line": 86, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 2879, + "end": 2881, + "loc": { + "start": { + "line": 86, + "column": 7 + }, + "end": { + "line": 86, + "column": 9 + } + }, + "name": "b7" + }, + "init": { + "type": "CallExpression", + "start": 2884, + "end": 2902, + "loc": { + "start": { + "line": 86, + "column": 12 + }, + "end": { + "line": 86, + "column": 30 + } + }, + "callee": { + "type": "Identifier", + "start": 2884, + "end": 2886, + "loc": { + "start": { + "line": 86, + "column": 12 + }, + "end": { + "line": 86, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 2886, + "end": 2900, + "loc": { + "start": { + "line": 86, + "column": 14 + }, + "end": { + "line": 86, + "column": 28 + } + }, + "params": [ + { + "type": "TSFunctionType", + "start": 2887, + "end": 2899, + "loc": { + "start": { + "line": 86, + "column": 15 + }, + "end": { + "line": 86, + "column": 27 + } + }, + "parameters": [ + { + "type": "Identifier", + "start": 2888, + "end": 2893, + "loc": { + "start": { + "line": 86, + "column": 16 + }, + "end": { + "line": 86, + "column": 21 + } + }, + "name": "b", + "optional": true, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 2890, + "end": 2893, + "loc": { + "start": { + "line": 86, + "column": 18 + }, + "end": { + "line": 86, + "column": 21 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 2892, + "end": 2893, + "loc": { + "start": { + "line": 86, + "column": 20 + }, + "end": { + "line": 86, + "column": 21 + } + }, + "typeName": { + "type": "Identifier", + "start": 2892, + "end": 2893, + "loc": { + "start": { + "line": 86, + "column": 20 + }, + "end": { + "line": 86, + "column": 21 + } + }, + "name": "T" + } + } + } + } + ], + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 2895, + "end": 2899, + "loc": { + "start": { + "line": 86, + "column": 23 + }, + "end": { + "line": 86, + "column": 27 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 2898, + "end": 2899, + "loc": { + "start": { + "line": 86, + "column": 26 + }, + "end": { + "line": 86, + "column": 27 + } + }, + "typeName": { + "type": "Identifier", + "start": 2898, + "end": 2899, + "loc": { + "start": { + "line": 86, + "column": 26 + }, + "end": { + "line": 86, + "column": 27 + } + }, + "name": "U" + } + } + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 2992, + "end": 3016, + "loc": { + "start": { + "line": 89, + "column": 1 + }, + "end": { + "line": 89, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 2998, + "end": 3015, + "loc": { + "start": { + "line": 89, + "column": 7 + }, + "end": { + "line": 89, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 2998, + "end": 3000, + "loc": { + "start": { + "line": 89, + "column": 7 + }, + "end": { + "line": 89, + "column": 9 + } + }, + "name": "b8" + }, + "init": { + "type": "CallExpression", + "start": 3003, + "end": 3015, + "loc": { + "start": { + "line": 89, + "column": 12 + }, + "end": { + "line": 89, + "column": 24 + } + }, + "callee": { + "type": "Identifier", + "start": 3003, + "end": 3005, + "loc": { + "start": { + "line": 89, + "column": 12 + }, + "end": { + "line": 89, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3005, + "end": 3013, + "loc": { + "start": { + "line": 89, + "column": 14 + }, + "end": { + "line": 89, + "column": 22 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 3006, + "end": 3012, + "loc": { + "start": { + "line": 89, + "column": 15 + }, + "end": { + "line": 89, + "column": 21 + } + }, + "elementTypes": [ + { + "type": "TSTypeReference", + "start": 3007, + "end": 3011, + "loc": { + "start": { + "line": 89, + "column": 16 + }, + "end": { + "line": 89, + "column": 20 + } + }, + "typeName": { + "type": "Identifier", + "start": 3007, + "end": 3008, + "loc": { + "start": { + "line": 89, + "column": 16 + }, + "end": { + "line": 89, + "column": 17 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3008, + "end": 3011, + "loc": { + "start": { + "line": 89, + "column": 17 + }, + "end": { + "line": 89, + "column": 20 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3009, + "end": 3010, + "loc": { + "start": { + "line": 89, + "column": 18 + }, + "end": { + "line": 89, + "column": 19 + } + }, + "typeName": { + "type": "Identifier", + "start": 3009, + "end": 3010, + "loc": { + "start": { + "line": 89, + "column": 18 + }, + "end": { + "line": 89, + "column": 19 + } + }, + "name": "A" + } + } + ] + } + } + ] + } + ] + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " a generic nested inside a tuple or object-type arg still parses as type arguments", + "start": 2906, + "end": 2990 + } + ] + }, + { + "type": "VariableDeclaration", + "start": 3018, + "end": 3045, + "loc": { + "start": { + "line": 90, + "column": 1 + }, + "end": { + "line": 90, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3024, + "end": 3044, + "loc": { + "start": { + "line": 90, + "column": 7 + }, + "end": { + "line": 90, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 3024, + "end": 3026, + "loc": { + "start": { + "line": 90, + "column": 7 + }, + "end": { + "line": 90, + "column": 9 + } + }, + "name": "b9" + }, + "init": { + "type": "CallExpression", + "start": 3029, + "end": 3044, + "loc": { + "start": { + "line": 90, + "column": 12 + }, + "end": { + "line": 90, + "column": 27 + } + }, + "callee": { + "type": "Identifier", + "start": 3029, + "end": 3031, + "loc": { + "start": { + "line": 90, + "column": 12 + }, + "end": { + "line": 90, + "column": 14 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3031, + "end": 3042, + "loc": { + "start": { + "line": 90, + "column": 14 + }, + "end": { + "line": 90, + "column": 25 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 3032, + "end": 3041, + "loc": { + "start": { + "line": 90, + "column": 15 + }, + "end": { + "line": 90, + "column": 24 + } + }, + "elementTypes": [ + { + "type": "TSTypeReference", + "start": 3033, + "end": 3034, + "loc": { + "start": { + "line": 90, + "column": 16 + }, + "end": { + "line": 90, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3033, + "end": 3034, + "loc": { + "start": { + "line": 90, + "column": 16 + }, + "end": { + "line": 90, + "column": 17 + } + }, + "name": "A" + } + }, + { + "type": "TSTypeReference", + "start": 3036, + "end": 3040, + "loc": { + "start": { + "line": 90, + "column": 19 + }, + "end": { + "line": 90, + "column": 23 + } + }, + "typeName": { + "type": "Identifier", + "start": 3036, + "end": 3037, + "loc": { + "start": { + "line": 90, + "column": 19 + }, + "end": { + "line": 90, + "column": 20 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3037, + "end": 3040, + "loc": { + "start": { + "line": 90, + "column": 20 + }, + "end": { + "line": 90, + "column": 23 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3038, + "end": 3039, + "loc": { + "start": { + "line": 90, + "column": 21 + }, + "end": { + "line": 90, + "column": 22 + } + }, + "typeName": { + "type": "Identifier", + "start": 3038, + "end": 3039, + "loc": { + "start": { + "line": 90, + "column": 21 + }, + "end": { + "line": 90, + "column": 22 + } + }, + "name": "B" + } + } + ] + } + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3047, + "end": 3077, + "loc": { + "start": { + "line": 91, + "column": 1 + }, + "end": { + "line": 91, + "column": 31 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3053, + "end": 3076, + "loc": { + "start": { + "line": 91, + "column": 7 + }, + "end": { + "line": 91, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 3053, + "end": 3056, + "loc": { + "start": { + "line": 91, + "column": 7 + }, + "end": { + "line": 91, + "column": 10 + } + }, + "name": "b10" + }, + "init": { + "type": "CallExpression", + "start": 3059, + "end": 3076, + "loc": { + "start": { + "line": 91, + "column": 13 + }, + "end": { + "line": 91, + "column": 30 + } + }, + "callee": { + "type": "Identifier", + "start": 3059, + "end": 3061, + "loc": { + "start": { + "line": 91, + "column": 13 + }, + "end": { + "line": 91, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3061, + "end": 3074, + "loc": { + "start": { + "line": 91, + "column": 15 + }, + "end": { + "line": 91, + "column": 28 + } + }, + "params": [ + { + "type": "TSTypeLiteral", + "start": 3062, + "end": 3073, + "loc": { + "start": { + "line": 91, + "column": 16 + }, + "end": { + "line": 91, + "column": 27 + } + }, + "members": [ + { + "type": "TSPropertySignature", + "start": 3064, + "end": 3071, + "loc": { + "start": { + "line": 91, + "column": 18 + }, + "end": { + "line": 91, + "column": 25 + } + }, + "computed": false, + "key": { + "type": "Identifier", + "start": 3064, + "end": 3065, + "loc": { + "start": { + "line": 91, + "column": 18 + }, + "end": { + "line": 91, + "column": 19 + } + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 3065, + "end": 3071, + "loc": { + "start": { + "line": 91, + "column": 19 + }, + "end": { + "line": 91, + "column": 25 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 3067, + "end": 3071, + "loc": { + "start": { + "line": 91, + "column": 21 + }, + "end": { + "line": 91, + "column": 25 + } + }, + "typeName": { + "type": "Identifier", + "start": 3067, + "end": 3068, + "loc": { + "start": { + "line": 91, + "column": 21 + }, + "end": { + "line": 91, + "column": 22 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3068, + "end": 3071, + "loc": { + "start": { + "line": 91, + "column": 22 + }, + "end": { + "line": 91, + "column": 25 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3069, + "end": 3070, + "loc": { + "start": { + "line": 91, + "column": 23 + }, + "end": { + "line": 91, + "column": 24 + } + }, + "typeName": { + "type": "Identifier", + "start": 3069, + "end": 3070, + "loc": { + "start": { + "line": 91, + "column": 23 + }, + "end": { + "line": 91, + "column": 24 + } + }, + "name": "B" + } + } + ] + } + } + } + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3079, + "end": 3107, + "loc": { + "start": { + "line": 92, + "column": 1 + }, + "end": { + "line": 92, + "column": 29 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3085, + "end": 3106, + "loc": { + "start": { + "line": 92, + "column": 7 + }, + "end": { + "line": 92, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 3085, + "end": 3088, + "loc": { + "start": { + "line": 92, + "column": 7 + }, + "end": { + "line": 92, + "column": 10 + } + }, + "name": "b11" + }, + "init": { + "type": "CallExpression", + "start": 3091, + "end": 3106, + "loc": { + "start": { + "line": 92, + "column": 13 + }, + "end": { + "line": 92, + "column": 28 + } + }, + "callee": { + "type": "Identifier", + "start": 3091, + "end": 3093, + "loc": { + "start": { + "line": 92, + "column": 13 + }, + "end": { + "line": 92, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3093, + "end": 3104, + "loc": { + "start": { + "line": 92, + "column": 15 + }, + "end": { + "line": 92, + "column": 26 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 3094, + "end": 3103, + "loc": { + "start": { + "line": 92, + "column": 16 + }, + "end": { + "line": 92, + "column": 25 + } + }, + "elementTypes": [ + { + "type": "TSTypeReference", + "start": 3095, + "end": 3102, + "loc": { + "start": { + "line": 92, + "column": 17 + }, + "end": { + "line": 92, + "column": 24 + } + }, + "typeName": { + "type": "Identifier", + "start": 3095, + "end": 3096, + "loc": { + "start": { + "line": 92, + "column": 17 + }, + "end": { + "line": 92, + "column": 18 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3096, + "end": 3102, + "loc": { + "start": { + "line": 92, + "column": 18 + }, + "end": { + "line": 92, + "column": 24 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3097, + "end": 3098, + "loc": { + "start": { + "line": 92, + "column": 19 + }, + "end": { + "line": 92, + "column": 20 + } + }, + "typeName": { + "type": "Identifier", + "start": 3097, + "end": 3098, + "loc": { + "start": { + "line": 92, + "column": 19 + }, + "end": { + "line": 92, + "column": 20 + } + }, + "name": "A" + } + }, + { + "type": "TSTypeReference", + "start": 3100, + "end": 3101, + "loc": { + "start": { + "line": 92, + "column": 22 + }, + "end": { + "line": 92, + "column": 23 + } + }, + "typeName": { + "type": "Identifier", + "start": 3100, + "end": 3101, + "loc": { + "start": { + "line": 92, + "column": 22 + }, + "end": { + "line": 92, + "column": 23 + } + }, + "name": "B" + } + } + ] + } + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3109, + "end": 3136, + "loc": { + "start": { + "line": 93, + "column": 1 + }, + "end": { + "line": 93, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3115, + "end": 3135, + "loc": { + "start": { + "line": 93, + "column": 7 + }, + "end": { + "line": 93, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 3115, + "end": 3118, + "loc": { + "start": { + "line": 93, + "column": 7 + }, + "end": { + "line": 93, + "column": 10 + } + }, + "name": "b12" + }, + "init": { + "type": "CallExpression", + "start": 3121, + "end": 3135, + "loc": { + "start": { + "line": 93, + "column": 13 + }, + "end": { + "line": 93, + "column": 27 + } + }, + "callee": { + "type": "Identifier", + "start": 3121, + "end": 3123, + "loc": { + "start": { + "line": 93, + "column": 13 + }, + "end": { + "line": 93, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3123, + "end": 3133, + "loc": { + "start": { + "line": 93, + "column": 15 + }, + "end": { + "line": 93, + "column": 25 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 3124, + "end": 3132, + "loc": { + "start": { + "line": 93, + "column": 16 + }, + "end": { + "line": 93, + "column": 24 + } + }, + "elementTypes": [ + { + "type": "TSArrayType", + "start": 3125, + "end": 3131, + "loc": { + "start": { + "line": 93, + "column": 17 + }, + "end": { + "line": 93, + "column": 23 + } + }, + "elementType": { + "type": "TSTypeReference", + "start": 3125, + "end": 3129, + "loc": { + "start": { + "line": 93, + "column": 17 + }, + "end": { + "line": 93, + "column": 21 + } + }, + "typeName": { + "type": "Identifier", + "start": 3125, + "end": 3126, + "loc": { + "start": { + "line": 93, + "column": 17 + }, + "end": { + "line": 93, + "column": 18 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3126, + "end": 3129, + "loc": { + "start": { + "line": 93, + "column": 18 + }, + "end": { + "line": 93, + "column": 21 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3127, + "end": 3128, + "loc": { + "start": { + "line": 93, + "column": 19 + }, + "end": { + "line": 93, + "column": 20 + } + }, + "typeName": { + "type": "Identifier", + "start": 3127, + "end": 3128, + "loc": { + "start": { + "line": 93, + "column": 19 + }, + "end": { + "line": 93, + "column": 20 + } + }, + "name": "A" + } + } + ] + } + } + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3138, + "end": 3166, + "loc": { + "start": { + "line": 94, + "column": 1 + }, + "end": { + "line": 94, + "column": 29 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3144, + "end": 3165, + "loc": { + "start": { + "line": 94, + "column": 7 + }, + "end": { + "line": 94, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 3144, + "end": 3147, + "loc": { + "start": { + "line": 94, + "column": 7 + }, + "end": { + "line": 94, + "column": 10 + } + }, + "name": "b13" + }, + "init": { + "type": "CallExpression", + "start": 3150, + "end": 3165, + "loc": { + "start": { + "line": 94, + "column": 13 + }, + "end": { + "line": 94, + "column": 28 + } + }, + "callee": { + "type": "Identifier", + "start": 3150, + "end": 3152, + "loc": { + "start": { + "line": 94, + "column": 13 + }, + "end": { + "line": 94, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3152, + "end": 3163, + "loc": { + "start": { + "line": 94, + "column": 15 + }, + "end": { + "line": 94, + "column": 26 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 3153, + "end": 3159, + "loc": { + "start": { + "line": 94, + "column": 16 + }, + "end": { + "line": 94, + "column": 22 + } + }, + "elementTypes": [ + { + "type": "TSTypeReference", + "start": 3154, + "end": 3158, + "loc": { + "start": { + "line": 94, + "column": 17 + }, + "end": { + "line": 94, + "column": 21 + } + }, + "typeName": { + "type": "Identifier", + "start": 3154, + "end": 3155, + "loc": { + "start": { + "line": 94, + "column": 17 + }, + "end": { + "line": 94, + "column": 18 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3155, + "end": 3158, + "loc": { + "start": { + "line": 94, + "column": 18 + }, + "end": { + "line": 94, + "column": 21 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3156, + "end": 3157, + "loc": { + "start": { + "line": 94, + "column": 19 + }, + "end": { + "line": 94, + "column": 20 + } + }, + "typeName": { + "type": "Identifier", + "start": 3156, + "end": 3157, + "loc": { + "start": { + "line": 94, + "column": 19 + }, + "end": { + "line": 94, + "column": 20 + } + }, + "name": "A" + } + } + ] + } + } + ] + }, + { + "type": "TSTypeReference", + "start": 3161, + "end": 3162, + "loc": { + "start": { + "line": 94, + "column": 24 + }, + "end": { + "line": 94, + "column": 25 + } + }, + "typeName": { + "type": "Identifier", + "start": 3161, + "end": 3162, + "loc": { + "start": { + "line": 94, + "column": 24 + }, + "end": { + "line": 94, + "column": 25 + } + }, + "name": "B" + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3168, + "end": 3195, + "loc": { + "start": { + "line": 95, + "column": 1 + }, + "end": { + "line": 95, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3174, + "end": 3194, + "loc": { + "start": { + "line": 95, + "column": 7 + }, + "end": { + "line": 95, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 3174, + "end": 3177, + "loc": { + "start": { + "line": 95, + "column": 7 + }, + "end": { + "line": 95, + "column": 10 + } + }, + "name": "b14" + }, + "init": { + "type": "CallExpression", + "start": 3180, + "end": 3194, + "loc": { + "start": { + "line": 95, + "column": 13 + }, + "end": { + "line": 95, + "column": 27 + } + }, + "callee": { + "type": "Identifier", + "start": 3180, + "end": 3182, + "loc": { + "start": { + "line": 95, + "column": 13 + }, + "end": { + "line": 95, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3182, + "end": 3192, + "loc": { + "start": { + "line": 95, + "column": 15 + }, + "end": { + "line": 95, + "column": 25 + } + }, + "params": [ + { + "type": "TSTupleType", + "start": 3183, + "end": 3191, + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 24 + } + }, + "elementTypes": [ + { + "type": "TSTupleType", + "start": 3184, + "end": 3190, + "loc": { + "start": { + "line": 95, + "column": 17 + }, + "end": { + "line": 95, + "column": 23 + } + }, + "elementTypes": [ + { + "type": "TSTypeReference", + "start": 3185, + "end": 3189, + "loc": { + "start": { + "line": 95, + "column": 18 + }, + "end": { + "line": 95, + "column": 22 + } + }, + "typeName": { + "type": "Identifier", + "start": 3185, + "end": 3186, + "loc": { + "start": { + "line": 95, + "column": 18 + }, + "end": { + "line": 95, + "column": 19 + } + }, + "name": "T" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3186, + "end": 3189, + "loc": { + "start": { + "line": 95, + "column": 19 + }, + "end": { + "line": 95, + "column": 22 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3187, + "end": 3188, + "loc": { + "start": { + "line": 95, + "column": 20 + }, + "end": { + "line": 95, + "column": 21 + } + }, + "typeName": { + "type": "Identifier", + "start": 3187, + "end": 3188, + "loc": { + "start": { + "line": 95, + "column": 20 + }, + "end": { + "line": 95, + "column": 21 + } + }, + "name": "A" + } + } + ] + } + } + ] + } + ] + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3307, + "end": 3328, + "loc": { + "start": { + "line": 99, + "column": 1 + }, + "end": { + "line": 99, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3313, + "end": 3327, + "loc": { + "start": { + "line": 99, + "column": 7 + }, + "end": { + "line": 99, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 3313, + "end": 3316, + "loc": { + "start": { + "line": 99, + "column": 7 + }, + "end": { + "line": 99, + "column": 10 + } + }, + "name": "b15" + }, + "init": { + "type": "TaggedTemplateExpression", + "start": 3319, + "end": 3327, + "loc": { + "start": { + "line": 99, + "column": 13 + }, + "end": { + "line": 99, + "column": 21 + } + }, + "tag": { + "type": "Identifier", + "start": 3319, + "end": 3321, + "loc": { + "start": { + "line": 99, + "column": 13 + }, + "end": { + "line": 99, + "column": 15 + } + }, + "name": "fn" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 3324, + "end": 3327, + "loc": { + "start": { + "line": 99, + "column": 18 + }, + "end": { + "line": 99, + "column": 21 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 3325, + "end": 3326, + "loc": { + "start": { + "line": 99, + "column": 19 + }, + "end": { + "line": 99, + "column": 20 + } + }, + "value": { + "raw": "b", + "cooked": "b" + }, + "tail": true + } + ] + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3321, + "end": 3324, + "loc": { + "start": { + "line": 99, + "column": 15 + }, + "end": { + "line": 99, + "column": 18 + } + }, + "params": [ + { + "type": "TSTypeReference", + "start": 3322, + "end": 3323, + "loc": { + "start": { + "line": 99, + "column": 16 + }, + "end": { + "line": 99, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3322, + "end": 3323, + "loc": { + "start": { + "line": 99, + "column": 16 + }, + "end": { + "line": 99, + "column": 17 + } + }, + "name": "A" + } + } + ] + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " a template literal after the closing `>` is a tagged template on the", + "start": 3198, + "end": 3269 + }, + { + "type": "Line", + "value": " instantiation, not a comparison", + "start": 3271, + "end": 3305 + } + ] + }, + { + "type": "VariableDeclaration", + "start": 3465, + "end": 3487, + "loc": { + "start": { + "line": 103, + "column": 1 + }, + "end": { + "line": 103, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3471, + "end": 3486, + "loc": { + "start": { + "line": 103, + "column": 7 + }, + "end": { + "line": 103, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 3471, + "end": 3474, + "loc": { + "start": { + "line": 103, + "column": 7 + }, + "end": { + "line": 103, + "column": 10 + } + }, + "name": "b16" + }, + "init": { + "type": "CallExpression", + "start": 3477, + "end": 3486, + "loc": { + "start": { + "line": 103, + "column": 13 + }, + "end": { + "line": 103, + "column": 22 + } + }, + "callee": { + "type": "Identifier", + "start": 3477, + "end": 3479, + "loc": { + "start": { + "line": 103, + "column": 13 + }, + "end": { + "line": 103, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3479, + "end": 3484, + "loc": { + "start": { + "line": 103, + "column": 15 + }, + "end": { + "line": 103, + "column": 20 + } + }, + "params": [ + { + "type": "TSArrayType", + "start": 3480, + "end": 3483, + "loc": { + "start": { + "line": 103, + "column": 16 + }, + "end": { + "line": 103, + "column": 19 + } + }, + "elementType": { + "type": "TSTypeReference", + "start": 3480, + "end": 3481, + "loc": { + "start": { + "line": 103, + "column": 16 + }, + "end": { + "line": 103, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3480, + "end": 3481, + "loc": { + "start": { + "line": 103, + "column": 16 + }, + "end": { + "line": 103, + "column": 17 + } + }, + "name": "A" + } + } + } + ] + } + } + } + ], + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " an indexed access, array, or conditional type argument still parses as type", + "start": 3331, + "end": 3409 + }, + { + "type": "Line", + "value": " arguments — the closing `>` is followed by a call", + "start": 3411, + "end": 3463 + } + ] + }, + { + "type": "VariableDeclaration", + "start": 3489, + "end": 3514, + "loc": { + "start": { + "line": 104, + "column": 1 + }, + "end": { + "line": 104, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3495, + "end": 3513, + "loc": { + "start": { + "line": 104, + "column": 7 + }, + "end": { + "line": 104, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 3495, + "end": 3498, + "loc": { + "start": { + "line": 104, + "column": 7 + }, + "end": { + "line": 104, + "column": 10 + } + }, + "name": "b17" + }, + "init": { + "type": "CallExpression", + "start": 3501, + "end": 3513, + "loc": { + "start": { + "line": 104, + "column": 13 + }, + "end": { + "line": 104, + "column": 25 + } + }, + "callee": { + "type": "Identifier", + "start": 3501, + "end": 3503, + "loc": { + "start": { + "line": 104, + "column": 13 + }, + "end": { + "line": 104, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3503, + "end": 3511, + "loc": { + "start": { + "line": 104, + "column": 15 + }, + "end": { + "line": 104, + "column": 23 + } + }, + "params": [ + { + "type": "TSIndexedAccessType", + "start": 3504, + "end": 3510, + "loc": { + "start": { + "line": 104, + "column": 16 + }, + "end": { + "line": 104, + "column": 22 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3504, + "end": 3505, + "loc": { + "start": { + "line": 104, + "column": 16 + }, + "end": { + "line": 104, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3504, + "end": 3505, + "loc": { + "start": { + "line": 104, + "column": 16 + }, + "end": { + "line": 104, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSLiteralType", + "start": 3506, + "end": 3509, + "loc": { + "start": { + "line": 104, + "column": 18 + }, + "end": { + "line": 104, + "column": 21 + } + }, + "literal": { + "type": "Literal", + "start": 3506, + "end": 3509, + "loc": { + "start": { + "line": 104, + "column": 18 + }, + "end": { + "line": 104, + "column": 21 + } + }, + "value": "b", + "raw": "'b'" + } + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3516, + "end": 3542, + "loc": { + "start": { + "line": 105, + "column": 1 + }, + "end": { + "line": 105, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3522, + "end": 3541, + "loc": { + "start": { + "line": 105, + "column": 7 + }, + "end": { + "line": 105, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 3522, + "end": 3525, + "loc": { + "start": { + "line": 105, + "column": 7 + }, + "end": { + "line": 105, + "column": 10 + } + }, + "name": "b18" + }, + "init": { + "type": "CallExpression", + "start": 3528, + "end": 3541, + "loc": { + "start": { + "line": 105, + "column": 13 + }, + "end": { + "line": 105, + "column": 26 + } + }, + "callee": { + "type": "Identifier", + "start": 3528, + "end": 3530, + "loc": { + "start": { + "line": 105, + "column": 13 + }, + "end": { + "line": 105, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3530, + "end": 3539, + "loc": { + "start": { + "line": 105, + "column": 15 + }, + "end": { + "line": 105, + "column": 24 + } + }, + "params": [ + { + "type": "TSIndexedAccessType", + "start": 3531, + "end": 3535, + "loc": { + "start": { + "line": 105, + "column": 16 + }, + "end": { + "line": 105, + "column": 20 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3531, + "end": 3532, + "loc": { + "start": { + "line": 105, + "column": 16 + }, + "end": { + "line": 105, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3531, + "end": 3532, + "loc": { + "start": { + "line": 105, + "column": 16 + }, + "end": { + "line": 105, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSTypeReference", + "start": 3533, + "end": 3534, + "loc": { + "start": { + "line": 105, + "column": 18 + }, + "end": { + "line": 105, + "column": 19 + } + }, + "typeName": { + "type": "Identifier", + "start": 3533, + "end": 3534, + "loc": { + "start": { + "line": 105, + "column": 18 + }, + "end": { + "line": 105, + "column": 19 + } + }, + "name": "B" + } + } + }, + { + "type": "TSTypeReference", + "start": 3537, + "end": 3538, + "loc": { + "start": { + "line": 105, + "column": 22 + }, + "end": { + "line": 105, + "column": 23 + } + }, + "typeName": { + "type": "Identifier", + "start": 3537, + "end": 3538, + "loc": { + "start": { + "line": 105, + "column": 22 + }, + "end": { + "line": 105, + "column": 23 + } + }, + "name": "C" + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3544, + "end": 3573, + "loc": { + "start": { + "line": 106, + "column": 1 + }, + "end": { + "line": 106, + "column": 30 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3550, + "end": 3572, + "loc": { + "start": { + "line": 106, + "column": 7 + }, + "end": { + "line": 106, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 3550, + "end": 3553, + "loc": { + "start": { + "line": 106, + "column": 7 + }, + "end": { + "line": 106, + "column": 10 + } + }, + "name": "b19" + }, + "init": { + "type": "CallExpression", + "start": 3556, + "end": 3572, + "loc": { + "start": { + "line": 106, + "column": 13 + }, + "end": { + "line": 106, + "column": 29 + } + }, + "callee": { + "type": "Identifier", + "start": 3556, + "end": 3558, + "loc": { + "start": { + "line": 106, + "column": 13 + }, + "end": { + "line": 106, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3558, + "end": 3570, + "loc": { + "start": { + "line": 106, + "column": 15 + }, + "end": { + "line": 106, + "column": 27 + } + }, + "params": [ + { + "type": "TSIndexedAccessType", + "start": 3559, + "end": 3569, + "loc": { + "start": { + "line": 106, + "column": 16 + }, + "end": { + "line": 106, + "column": 26 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3559, + "end": 3560, + "loc": { + "start": { + "line": 106, + "column": 16 + }, + "end": { + "line": 106, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3559, + "end": 3560, + "loc": { + "start": { + "line": 106, + "column": 16 + }, + "end": { + "line": 106, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSTypeOperator", + "start": 3561, + "end": 3568, + "loc": { + "start": { + "line": 106, + "column": 18 + }, + "end": { + "line": 106, + "column": 25 + } + }, + "operator": "keyof", + "typeAnnotation": { + "type": "TSTypeReference", + "start": 3567, + "end": 3568, + "loc": { + "start": { + "line": 106, + "column": 24 + }, + "end": { + "line": 106, + "column": 25 + } + }, + "typeName": { + "type": "Identifier", + "start": 3567, + "end": 3568, + "loc": { + "start": { + "line": 106, + "column": 24 + }, + "end": { + "line": 106, + "column": 25 + } + }, + "name": "B" + } + } + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3575, + "end": 3605, + "loc": { + "start": { + "line": 107, + "column": 1 + }, + "end": { + "line": 107, + "column": 31 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3581, + "end": 3604, + "loc": { + "start": { + "line": 107, + "column": 7 + }, + "end": { + "line": 107, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 3581, + "end": 3584, + "loc": { + "start": { + "line": 107, + "column": 7 + }, + "end": { + "line": 107, + "column": 10 + } + }, + "name": "b20" + }, + "init": { + "type": "CallExpression", + "start": 3587, + "end": 3604, + "loc": { + "start": { + "line": 107, + "column": 13 + }, + "end": { + "line": 107, + "column": 30 + } + }, + "callee": { + "type": "Identifier", + "start": 3587, + "end": 3589, + "loc": { + "start": { + "line": 107, + "column": 13 + }, + "end": { + "line": 107, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3589, + "end": 3602, + "loc": { + "start": { + "line": 107, + "column": 15 + }, + "end": { + "line": 107, + "column": 28 + } + }, + "params": [ + { + "type": "TSIndexedAccessType", + "start": 3590, + "end": 3601, + "loc": { + "start": { + "line": 107, + "column": 16 + }, + "end": { + "line": 107, + "column": 27 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3590, + "end": 3591, + "loc": { + "start": { + "line": 107, + "column": 16 + }, + "end": { + "line": 107, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3590, + "end": 3591, + "loc": { + "start": { + "line": 107, + "column": 16 + }, + "end": { + "line": 107, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSTypeQuery", + "start": 3592, + "end": 3600, + "loc": { + "start": { + "line": 107, + "column": 18 + }, + "end": { + "line": 107, + "column": 26 + } + }, + "exprName": { + "type": "Identifier", + "start": 3599, + "end": 3600, + "loc": { + "start": { + "line": 107, + "column": 25 + }, + "end": { + "line": 107, + "column": 26 + } + }, + "name": "b" + } + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3607, + "end": 3633, + "loc": { + "start": { + "line": 108, + "column": 1 + }, + "end": { + "line": 108, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3613, + "end": 3632, + "loc": { + "start": { + "line": 108, + "column": 7 + }, + "end": { + "line": 108, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 3613, + "end": 3616, + "loc": { + "start": { + "line": 108, + "column": 7 + }, + "end": { + "line": 108, + "column": 10 + } + }, + "name": "b21" + }, + "init": { + "type": "CallExpression", + "start": 3619, + "end": 3632, + "loc": { + "start": { + "line": 108, + "column": 13 + }, + "end": { + "line": 108, + "column": 26 + } + }, + "callee": { + "type": "Identifier", + "start": 3619, + "end": 3621, + "loc": { + "start": { + "line": 108, + "column": 13 + }, + "end": { + "line": 108, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3621, + "end": 3630, + "loc": { + "start": { + "line": 108, + "column": 15 + }, + "end": { + "line": 108, + "column": 24 + } + }, + "params": [ + { + "type": "TSIndexedAccessType", + "start": 3622, + "end": 3629, + "loc": { + "start": { + "line": 108, + "column": 16 + }, + "end": { + "line": 108, + "column": 23 + } + }, + "objectType": { + "type": "TSIndexedAccessType", + "start": 3622, + "end": 3626, + "loc": { + "start": { + "line": 108, + "column": 16 + }, + "end": { + "line": 108, + "column": 20 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3622, + "end": 3623, + "loc": { + "start": { + "line": 108, + "column": 16 + }, + "end": { + "line": 108, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3622, + "end": 3623, + "loc": { + "start": { + "line": 108, + "column": 16 + }, + "end": { + "line": 108, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSTypeReference", + "start": 3624, + "end": 3625, + "loc": { + "start": { + "line": 108, + "column": 18 + }, + "end": { + "line": 108, + "column": 19 + } + }, + "typeName": { + "type": "Identifier", + "start": 3624, + "end": 3625, + "loc": { + "start": { + "line": 108, + "column": 18 + }, + "end": { + "line": 108, + "column": 19 + } + }, + "name": "B" + } + } + }, + "indexType": { + "type": "TSTypeReference", + "start": 3627, + "end": 3628, + "loc": { + "start": { + "line": 108, + "column": 21 + }, + "end": { + "line": 108, + "column": 22 + } + }, + "typeName": { + "type": "Identifier", + "start": 3627, + "end": 3628, + "loc": { + "start": { + "line": 108, + "column": 21 + }, + "end": { + "line": 108, + "column": 22 + } + }, + "name": "C" + } + } + } + ] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 3635, + "end": 3673, + "loc": { + "start": { + "line": 109, + "column": 1 + }, + "end": { + "line": 109, + "column": 39 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 3641, + "end": 3672, + "loc": { + "start": { + "line": 109, + "column": 7 + }, + "end": { + "line": 109, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 3641, + "end": 3644, + "loc": { + "start": { + "line": 109, + "column": 7 + }, + "end": { + "line": 109, + "column": 10 + } + }, + "name": "b22" + }, + "init": { + "type": "CallExpression", + "start": 3647, + "end": 3672, + "loc": { + "start": { + "line": 109, + "column": 13 + }, + "end": { + "line": 109, + "column": 38 + } + }, + "callee": { + "type": "Identifier", + "start": 3647, + "end": 3649, + "loc": { + "start": { + "line": 109, + "column": 13 + }, + "end": { + "line": 109, + "column": 15 + } + }, + "name": "fn" + }, + "arguments": [], + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 3649, + "end": 3670, + "loc": { + "start": { + "line": 109, + "column": 15 + }, + "end": { + "line": 109, + "column": 36 + } + }, + "params": [ + { + "type": "TSConditionalType", + "start": 3650, + "end": 3669, + "loc": { + "start": { + "line": 109, + "column": 16 + }, + "end": { + "line": 109, + "column": 35 + } + }, + "checkType": { + "type": "TSTypeReference", + "start": 3650, + "end": 3651, "loc": { "start": { - "line": 39, - "column": 15 + "line": 109, + "column": 16 }, "end": { - "line": 39, - "column": 18 + "line": 109, + "column": 17 } }, - "value": "b", - "raw": "'b'" + "typeName": { + "type": "Identifier", + "start": 3650, + "end": 3651, + "loc": { + "start": { + "line": 109, + "column": 16 + }, + "end": { + "line": 109, + "column": 17 + } + }, + "name": "T" + } + }, + "extendsType": { + "type": "TSTypeReference", + "start": 3660, + "end": 3661, + "loc": { + "start": { + "line": 109, + "column": 26 + }, + "end": { + "line": 109, + "column": 27 + } + }, + "typeName": { + "type": "Identifier", + "start": 3660, + "end": 3661, + "loc": { + "start": { + "line": 109, + "column": 26 + }, + "end": { + "line": 109, + "column": 27 + } + }, + "name": "U" + } + }, + "trueType": { + "type": "TSTypeReference", + "start": 3664, + "end": 3665, + "loc": { + "start": { + "line": 109, + "column": 30 + }, + "end": { + "line": 109, + "column": 31 + } + }, + "typeName": { + "type": "Identifier", + "start": 3664, + "end": 3665, + "loc": { + "start": { + "line": 109, + "column": 30 + }, + "end": { + "line": 109, + "column": 31 + } + }, + "name": "A" + } + }, + "falseType": { + "type": "TSTypeReference", + "start": 3668, + "end": 3669, + "loc": { + "start": { + "line": 109, + "column": 34 + }, + "end": { + "line": 109, + "column": 35 + } + }, + "typeName": { + "type": "Identifier", + "start": 3668, + "end": 3669, + "loc": { + "start": { + "line": 109, + "column": 34 + }, + "end": { + "line": 109, + "column": 35 + } + }, + "name": "B" + } } } ] @@ -3395,93 +11927,79 @@ } } ], - "kind": "const", - "leadingComments": [ - { - "type": "Line", - "value": " genuine instantiation with a literal/keyword/object/tuple/numeric type arg, or a", - "start": 1161, - "end": 1244 - }, - { - "type": "Line", - "value": " function type with an optional param, still parses as type arguments", - "start": 1246, - "end": 1317 - } - ] + "kind": "const" }, { "type": "VariableDeclaration", - "start": 1342, - "end": 1364, + "start": 3834, + "end": 3861, "loc": { "start": { - "line": 40, + "line": 113, "column": 1 }, "end": { - "line": 40, - "column": 23 + "line": 113, + "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1348, - "end": 1363, + "start": 3840, + "end": 3860, "loc": { "start": { - "line": 40, + "line": 113, "column": 7 }, "end": { - "line": 40, - "column": 22 + "line": 113, + "column": 27 } }, "id": { "type": "Identifier", - "start": 1348, - "end": 1350, + "start": 3840, + "end": 3843, "loc": { "start": { - "line": 40, + "line": 113, "column": 7 }, "end": { - "line": 40, - "column": 9 + "line": 113, + "column": 10 } }, - "name": "b2" + "name": "b23" }, "init": { "type": "CallExpression", - "start": 1353, - "end": 1363, + "start": 3846, + "end": 3860, "loc": { "start": { - "line": 40, - "column": 12 + "line": 113, + "column": 13 }, "end": { - "line": 40, - "column": 22 + "line": 113, + "column": 27 } }, "callee": { "type": "Identifier", - "start": 1353, - "end": 1355, + "start": 3846, + "end": 3848, "loc": { "start": { - "line": 40, - "column": 12 + "line": 113, + "column": 13 }, "end": { - "line": 40, - "column": 14 + "line": 113, + "column": 15 } }, "name": "fn" @@ -3489,49 +12007,142 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1355, - "end": 1361, + "start": 3848, + "end": 3858, "loc": { "start": { - "line": 40, - "column": 14 + "line": 113, + "column": 15 }, "end": { - "line": 40, - "column": 20 + "line": 113, + "column": 25 } }, "params": [ { - "type": "TSLiteralType", - "start": 1356, - "end": 1360, + "type": "TSIndexedAccessType", + "start": 3849, + "end": 3857, "loc": { "start": { - "line": 40, - "column": 15 + "line": 113, + "column": 16 }, "end": { - "line": 40, - "column": 19 + "line": 113, + "column": 24 } }, - "literal": { - "type": "Literal", - "start": 1356, - "end": 1360, + "objectType": { + "type": "TSTypeReference", + "start": 3849, + "end": 3850, "loc": { "start": { - "line": 40, - "column": 15 + "line": 113, + "column": 16 }, "end": { - "line": 40, - "column": 19 + "line": 113, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3849, + "end": 3850, + "loc": { + "start": { + "line": 113, + "column": 16 + }, + "end": { + "line": 113, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSUnionType", + "start": 3851, + "end": 3856, + "loc": { + "start": { + "line": 113, + "column": 18 + }, + "end": { + "line": 113, + "column": 23 + } + }, + "types": [ + { + "type": "TSTypeReference", + "start": 3851, + "end": 3852, + "loc": { + "start": { + "line": 113, + "column": 18 + }, + "end": { + "line": 113, + "column": 19 + } + }, + "typeName": { + "type": "Identifier", + "start": 3851, + "end": 3852, + "loc": { + "start": { + "line": 113, + "column": 18 + }, + "end": { + "line": 113, + "column": 19 + } + }, + "name": "B" + } + }, + { + "type": "TSTypeReference", + "start": 3855, + "end": 3856, + "loc": { + "start": { + "line": 113, + "column": 22 + }, + "end": { + "line": 113, + "column": 23 + } + }, + "typeName": { + "type": "Identifier", + "start": 3855, + "end": 3856, + "loc": { + "start": { + "line": 113, + "column": 22 + }, + "end": { + "line": 113, + "column": 23 + } + }, + "name": "C" + } } - }, - "value": true, - "raw": "true" + ] } } ] @@ -3539,79 +12150,93 @@ } } ], - "kind": "const" + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " every index content that is itself a valid type — union, intersection, nested", + "start": 3676, + "end": 3756 + }, + { + "type": "Line", + "value": " index, numeric literal, and conditional — makes the list type arguments", + "start": 3758, + "end": 3832 + } + ] }, { "type": "VariableDeclaration", - "start": 1366, - "end": 1390, + "start": 3863, + "end": 3890, "loc": { "start": { - "line": 41, + "line": 114, "column": 1 }, "end": { - "line": 41, - "column": 25 + "line": 114, + "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1372, - "end": 1389, + "start": 3869, + "end": 3889, "loc": { "start": { - "line": 41, + "line": 114, "column": 7 }, "end": { - "line": 41, - "column": 24 + "line": 114, + "column": 27 } }, "id": { "type": "Identifier", - "start": 1372, - "end": 1374, + "start": 3869, + "end": 3872, "loc": { "start": { - "line": 41, + "line": 114, "column": 7 }, "end": { - "line": 41, - "column": 9 + "line": 114, + "column": 10 } }, - "name": "b3" + "name": "b24" }, "init": { "type": "CallExpression", - "start": 1377, - "end": 1389, + "start": 3875, + "end": 3889, "loc": { "start": { - "line": 41, - "column": 12 + "line": 114, + "column": 13 }, "end": { - "line": 41, - "column": 24 + "line": 114, + "column": 27 } }, "callee": { "type": "Identifier", - "start": 1377, - "end": 1379, + "start": 3875, + "end": 3877, "loc": { "start": { - "line": 41, - "column": 12 + "line": 114, + "column": 13 }, "end": { - "line": 41, - "column": 14 + "line": 114, + "column": 15 } }, "name": "fn" @@ -3619,32 +12244,142 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1379, - "end": 1387, + "start": 3877, + "end": 3887, "loc": { "start": { - "line": 41, - "column": 14 + "line": 114, + "column": 15 }, "end": { - "line": 41, - "column": 22 + "line": 114, + "column": 25 } }, "params": [ { - "type": "TSStringKeyword", - "start": 1380, - "end": 1386, + "type": "TSIndexedAccessType", + "start": 3878, + "end": 3886, "loc": { "start": { - "line": 41, - "column": 15 + "line": 114, + "column": 16 }, "end": { - "line": 41, - "column": 21 + "line": 114, + "column": 24 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3878, + "end": 3879, + "loc": { + "start": { + "line": 114, + "column": 16 + }, + "end": { + "line": 114, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3878, + "end": 3879, + "loc": { + "start": { + "line": 114, + "column": 16 + }, + "end": { + "line": 114, + "column": 17 + } + }, + "name": "A" } + }, + "indexType": { + "type": "TSIntersectionType", + "start": 3880, + "end": 3885, + "loc": { + "start": { + "line": 114, + "column": 18 + }, + "end": { + "line": 114, + "column": 23 + } + }, + "types": [ + { + "type": "TSTypeReference", + "start": 3880, + "end": 3881, + "loc": { + "start": { + "line": 114, + "column": 18 + }, + "end": { + "line": 114, + "column": 19 + } + }, + "typeName": { + "type": "Identifier", + "start": 3880, + "end": 3881, + "loc": { + "start": { + "line": 114, + "column": 18 + }, + "end": { + "line": 114, + "column": 19 + } + }, + "name": "B" + } + }, + { + "type": "TSTypeReference", + "start": 3884, + "end": 3885, + "loc": { + "start": { + "line": 114, + "column": 22 + }, + "end": { + "line": 114, + "column": 23 + } + }, + "typeName": { + "type": "Identifier", + "start": 3884, + "end": 3885, + "loc": { + "start": { + "line": 114, + "column": 22 + }, + "end": { + "line": 114, + "column": 23 + } + }, + "name": "C" + } + } + ] } } ] @@ -3656,75 +12391,75 @@ }, { "type": "VariableDeclaration", - "start": 1392, - "end": 1423, + "start": 3892, + "end": 3918, "loc": { "start": { - "line": 42, + "line": 115, "column": 1 }, "end": { - "line": 42, - "column": 32 + "line": 115, + "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1398, - "end": 1422, + "start": 3898, + "end": 3917, "loc": { "start": { - "line": 42, + "line": 115, "column": 7 }, "end": { - "line": 42, - "column": 31 + "line": 115, + "column": 26 } }, "id": { "type": "Identifier", - "start": 1398, - "end": 1400, + "start": 3898, + "end": 3901, "loc": { "start": { - "line": 42, + "line": 115, "column": 7 }, "end": { - "line": 42, - "column": 9 + "line": 115, + "column": 10 } }, - "name": "b4" + "name": "b25" }, "init": { "type": "CallExpression", - "start": 1403, - "end": 1422, + "start": 3904, + "end": 3917, "loc": { "start": { - "line": 42, - "column": 12 + "line": 115, + "column": 13 }, "end": { - "line": 42, - "column": 31 + "line": 115, + "column": 26 } }, "callee": { "type": "Identifier", - "start": 1403, - "end": 1405, + "start": 3904, + "end": 3906, "loc": { "start": { - "line": 42, - "column": 12 + "line": 115, + "column": 13 }, "end": { - "line": 42, - "column": 14 + "line": 115, + "column": 15 } }, "name": "fn" @@ -3732,97 +12467,141 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1405, - "end": 1420, + "start": 3906, + "end": 3915, "loc": { "start": { - "line": 42, - "column": 14 + "line": 115, + "column": 15 }, "end": { - "line": 42, - "column": 29 + "line": 115, + "column": 24 } }, "params": [ { - "type": "TSTypeLiteral", - "start": 1406, - "end": 1419, + "type": "TSIndexedAccessType", + "start": 3907, + "end": 3914, "loc": { "start": { - "line": 42, - "column": 15 + "line": 115, + "column": 16 }, "end": { - "line": 42, - "column": 28 + "line": 115, + "column": 23 } }, - "members": [ - { - "type": "TSPropertySignature", - "start": 1408, - "end": 1417, + "objectType": { + "type": "TSTypeReference", + "start": 3907, + "end": 3908, + "loc": { + "start": { + "line": 115, + "column": 16 + }, + "end": { + "line": 115, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3907, + "end": 3908, "loc": { "start": { - "line": 42, + "line": 115, + "column": 16 + }, + "end": { + "line": 115, "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSIndexedAccessType", + "start": 3909, + "end": 3913, + "loc": { + "start": { + "line": 115, + "column": 18 + }, + "end": { + "line": 115, + "column": 22 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 3909, + "end": 3910, + "loc": { + "start": { + "line": 115, + "column": 18 }, "end": { - "line": 42, - "column": 26 + "line": 115, + "column": 19 } }, - "computed": false, - "key": { + "typeName": { "type": "Identifier", - "start": 1408, - "end": 1409, + "start": 3909, + "end": 3910, "loc": { "start": { - "line": 42, - "column": 17 + "line": 115, + "column": 18 }, "end": { - "line": 42, - "column": 18 + "line": 115, + "column": 19 } }, - "name": "a" + "name": "B" + } + }, + "indexType": { + "type": "TSTypeReference", + "start": 3911, + "end": 3912, + "loc": { + "start": { + "line": 115, + "column": 20 + }, + "end": { + "line": 115, + "column": 21 + } }, - "typeAnnotation": { - "type": "TSTypeAnnotation", - "start": 1409, - "end": 1417, + "typeName": { + "type": "Identifier", + "start": 3911, + "end": 3912, "loc": { "start": { - "line": 42, - "column": 18 + "line": 115, + "column": 20 }, "end": { - "line": 42, - "column": 26 + "line": 115, + "column": 21 } }, - "typeAnnotation": { - "type": "TSNumberKeyword", - "start": 1411, - "end": 1417, - "loc": { - "start": { - "line": 42, - "column": 20 - }, - "end": { - "line": 42, - "column": 26 - } - } - } + "name": "C" } } - ] + } } ] } @@ -3833,75 +12612,75 @@ }, { "type": "VariableDeclaration", - "start": 1425, - "end": 1449, + "start": 3920, + "end": 3943, "loc": { "start": { - "line": 43, + "line": 116, "column": 1 }, "end": { - "line": 43, - "column": 25 + "line": 116, + "column": 24 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1431, - "end": 1448, + "start": 3926, + "end": 3942, "loc": { "start": { - "line": 43, + "line": 116, "column": 7 }, "end": { - "line": 43, - "column": 24 + "line": 116, + "column": 23 } }, "id": { "type": "Identifier", - "start": 1431, - "end": 1433, + "start": 3926, + "end": 3929, "loc": { "start": { - "line": 43, + "line": 116, "column": 7 }, "end": { - "line": 43, - "column": 9 + "line": 116, + "column": 10 } }, - "name": "b5" + "name": "b26" }, "init": { "type": "CallExpression", - "start": 1436, - "end": 1448, + "start": 3932, + "end": 3942, "loc": { "start": { - "line": 43, - "column": 12 + "line": 116, + "column": 13 }, "end": { - "line": 43, - "column": 24 + "line": 116, + "column": 23 } }, "callee": { "type": "Identifier", - "start": 1436, - "end": 1438, + "start": 3932, + "end": 3934, "loc": { "start": { - "line": 43, - "column": 12 + "line": 116, + "column": 13 }, "end": { - "line": 43, - "column": 14 + "line": 116, + "column": 15 } }, "name": "fn" @@ -3909,97 +12688,96 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1438, - "end": 1446, + "start": 3934, + "end": 3940, "loc": { "start": { - "line": 43, - "column": 14 + "line": 116, + "column": 15 }, "end": { - "line": 43, - "column": 22 + "line": 116, + "column": 21 } }, "params": [ { - "type": "TSTupleType", - "start": 1439, - "end": 1445, + "type": "TSIndexedAccessType", + "start": 3935, + "end": 3939, "loc": { "start": { - "line": 43, - "column": 15 + "line": 116, + "column": 16 }, "end": { - "line": 43, - "column": 21 + "line": 116, + "column": 20 } }, - "elementTypes": [ - { - "type": "TSTypeReference", - "start": 1440, - "end": 1441, + "objectType": { + "type": "TSTypeReference", + "start": 3935, + "end": 3936, + "loc": { + "start": { + "line": 116, + "column": 16 + }, + "end": { + "line": 116, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 3935, + "end": 3936, "loc": { "start": { - "line": 43, + "line": 116, "column": 16 }, "end": { - "line": 43, + "line": 116, "column": 17 } }, - "typeName": { - "type": "Identifier", - "start": 1440, - "end": 1441, - "loc": { - "start": { - "line": 43, - "column": 16 - }, - "end": { - "line": 43, - "column": 17 - } - }, - "name": "A" + "name": "A" + } + }, + "indexType": { + "type": "TSLiteralType", + "start": 3937, + "end": 3938, + "loc": { + "start": { + "line": 116, + "column": 18 + }, + "end": { + "line": 116, + "column": 19 } }, - { - "type": "TSTypeReference", - "start": 1443, - "end": 1444, + "literal": { + "type": "Literal", + "start": 3937, + "end": 3938, "loc": { "start": { - "line": 43, - "column": 19 + "line": 116, + "column": 18 }, "end": { - "line": 43, - "column": 20 + "line": 116, + "column": 19 } }, - "typeName": { - "type": "Identifier", - "start": 1443, - "end": 1444, - "loc": { - "start": { - "line": 43, - "column": 19 - }, - "end": { - "line": 43, - "column": 20 - } - }, - "name": "B" - } + "value": 0, + "raw": "0" } - ] + } } ] } @@ -4010,75 +12788,75 @@ }, { "type": "VariableDeclaration", - "start": 1451, - "end": 1470, + "start": 3945, + "end": 3969, "loc": { "start": { - "line": 44, + "line": 117, "column": 1 }, "end": { - "line": 44, - "column": 20 + "line": 117, + "column": 25 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1457, - "end": 1469, + "start": 3951, + "end": 3968, "loc": { "start": { - "line": 44, + "line": 117, "column": 7 }, "end": { - "line": 44, - "column": 19 + "line": 117, + "column": 24 } }, "id": { "type": "Identifier", - "start": 1457, - "end": 1459, + "start": 3951, + "end": 3954, "loc": { "start": { - "line": 44, + "line": 117, "column": 7 }, "end": { - "line": 44, - "column": 9 + "line": 117, + "column": 10 } }, - "name": "b6" + "name": "b27" }, "init": { "type": "CallExpression", - "start": 1462, - "end": 1469, + "start": 3957, + "end": 3968, "loc": { "start": { - "line": 44, - "column": 12 + "line": 117, + "column": 13 }, "end": { - "line": 44, - "column": 19 + "line": 117, + "column": 24 } }, "callee": { "type": "Identifier", - "start": 1462, - "end": 1464, + "start": 3957, + "end": 3959, "loc": { "start": { - "line": 44, - "column": 12 + "line": 117, + "column": 13 }, "end": { - "line": 44, - "column": 14 + "line": 117, + "column": 15 } }, "name": "fn" @@ -4086,49 +12864,112 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1464, - "end": 1467, + "start": 3959, + "end": 3966, "loc": { "start": { - "line": 44, - "column": 14 + "line": 117, + "column": 15 }, "end": { - "line": 44, - "column": 17 + "line": 117, + "column": 22 } }, "params": [ { - "type": "TSLiteralType", - "start": 1465, - "end": 1466, + "type": "TSIndexedAccessType", + "start": 3960, + "end": 3965, "loc": { "start": { - "line": 44, - "column": 15 + "line": 117, + "column": 16 }, "end": { - "line": 44, - "column": 16 + "line": 117, + "column": 21 } }, - "literal": { - "type": "Literal", - "start": 1465, - "end": 1466, + "objectType": { + "type": "TSTypeReference", + "start": 3960, + "end": 3961, "loc": { "start": { - "line": 44, - "column": 15 + "line": 117, + "column": 16 }, "end": { - "line": 44, - "column": 16 + "line": 117, + "column": 17 } }, - "value": 1, - "raw": "1" + "typeName": { + "type": "Identifier", + "start": 3960, + "end": 3961, + "loc": { + "start": { + "line": 117, + "column": 16 + }, + "end": { + "line": 117, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSLiteralType", + "start": 3962, + "end": 3964, + "loc": { + "start": { + "line": 117, + "column": 18 + }, + "end": { + "line": 117, + "column": 20 + } + }, + "literal": { + "type": "UnaryExpression", + "start": 3962, + "end": 3964, + "loc": { + "start": { + "line": 117, + "column": 18 + }, + "end": { + "line": 117, + "column": 20 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 3963, + "end": 3964, + "loc": { + "start": { + "line": 117, + "column": 19 + }, + "end": { + "line": 117, + "column": 20 + } + }, + "value": 1, + "raw": "1" + } + } } } ] @@ -4140,75 +12981,75 @@ }, { "type": "VariableDeclaration", - "start": 1472, - "end": 1502, + "start": 3971, + "end": 4012, "loc": { "start": { - "line": 45, + "line": 118, "column": 1 }, "end": { - "line": 45, - "column": 31 + "line": 118, + "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1478, - "end": 1501, + "start": 3977, + "end": 4011, "loc": { "start": { - "line": 45, + "line": 118, "column": 7 }, "end": { - "line": 45, - "column": 30 + "line": 118, + "column": 41 } }, "id": { "type": "Identifier", - "start": 1478, - "end": 1480, + "start": 3977, + "end": 3980, "loc": { "start": { - "line": 45, + "line": 118, "column": 7 }, "end": { - "line": 45, - "column": 9 + "line": 118, + "column": 10 } }, - "name": "b7" + "name": "b28" }, "init": { "type": "CallExpression", - "start": 1483, - "end": 1501, + "start": 3983, + "end": 4011, "loc": { "start": { - "line": 45, - "column": 12 + "line": 118, + "column": 13 }, "end": { - "line": 45, - "column": 30 + "line": 118, + "column": 41 } }, "callee": { "type": "Identifier", - "start": 1483, - "end": 1485, + "start": 3983, + "end": 3985, "loc": { "start": { - "line": 45, - "column": 12 + "line": 118, + "column": 13 }, "end": { - "line": 45, - "column": 14 + "line": 118, + "column": 15 } }, "name": "fn" @@ -4216,141 +13057,200 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1485, - "end": 1499, + "start": 3985, + "end": 4009, "loc": { "start": { - "line": 45, - "column": 14 + "line": 118, + "column": 15 }, "end": { - "line": 45, - "column": 28 + "line": 118, + "column": 39 } }, "params": [ { - "type": "TSFunctionType", - "start": 1486, - "end": 1498, + "type": "TSIndexedAccessType", + "start": 3986, + "end": 4008, "loc": { "start": { - "line": 45, - "column": 15 + "line": 118, + "column": 16 }, "end": { - "line": 45, - "column": 27 + "line": 118, + "column": 38 } }, - "parameters": [ - { + "objectType": { + "type": "TSTypeReference", + "start": 3986, + "end": 3987, + "loc": { + "start": { + "line": 118, + "column": 16 + }, + "end": { + "line": 118, + "column": 17 + } + }, + "typeName": { "type": "Identifier", - "start": 1487, - "end": 1492, + "start": 3986, + "end": 3987, "loc": { "start": { - "line": 45, + "line": 118, "column": 16 }, "end": { - "line": 45, - "column": 21 + "line": 118, + "column": 17 } }, - "name": "b", - "optional": true, - "typeAnnotation": { - "type": "TSTypeAnnotation", - "start": 1489, - "end": 1492, + "name": "A" + } + }, + "indexType": { + "type": "TSConditionalType", + "start": 3988, + "end": 4007, + "loc": { + "start": { + "line": 118, + "column": 18 + }, + "end": { + "line": 118, + "column": 37 + } + }, + "checkType": { + "type": "TSTypeReference", + "start": 3988, + "end": 3989, + "loc": { + "start": { + "line": 118, + "column": 18 + }, + "end": { + "line": 118, + "column": 19 + } + }, + "typeName": { + "type": "Identifier", + "start": 3988, + "end": 3989, "loc": { "start": { - "line": 45, + "line": 118, "column": 18 }, "end": { - "line": 45, - "column": 21 + "line": 118, + "column": 19 } }, - "typeAnnotation": { - "type": "TSTypeReference", - "start": 1491, - "end": 1492, - "loc": { - "start": { - "line": 45, - "column": 20 - }, - "end": { - "line": 45, - "column": 21 - } + "name": "B" + } + }, + "extendsType": { + "type": "TSTypeReference", + "start": 3998, + "end": 3999, + "loc": { + "start": { + "line": 118, + "column": 28 + }, + "end": { + "line": 118, + "column": 29 + } + }, + "typeName": { + "type": "Identifier", + "start": 3998, + "end": 3999, + "loc": { + "start": { + "line": 118, + "column": 28 }, - "typeName": { - "type": "Identifier", - "start": 1491, - "end": 1492, - "loc": { - "start": { - "line": 45, - "column": 20 - }, - "end": { - "line": 45, - "column": 21 - } - }, - "name": "T" + "end": { + "line": 118, + "column": 29 } - } - } - } - ], - "typeAnnotation": { - "type": "TSTypeAnnotation", - "start": 1494, - "end": 1498, - "loc": { - "start": { - "line": 45, - "column": 23 + }, + "name": "C" + } + }, + "trueType": { + "type": "TSTypeReference", + "start": 4002, + "end": 4003, + "loc": { + "start": { + "line": 118, + "column": 32 + }, + "end": { + "line": 118, + "column": 33 + } }, - "end": { - "line": 45, - "column": 27 + "typeName": { + "type": "Identifier", + "start": 4002, + "end": 4003, + "loc": { + "start": { + "line": 118, + "column": 32 + }, + "end": { + "line": 118, + "column": 33 + } + }, + "name": "D" } }, - "typeAnnotation": { + "falseType": { "type": "TSTypeReference", - "start": 1497, - "end": 1498, + "start": 4006, + "end": 4007, "loc": { "start": { - "line": 45, - "column": 26 + "line": 118, + "column": 36 }, "end": { - "line": 45, - "column": 27 + "line": 118, + "column": 37 } }, "typeName": { "type": "Identifier", - "start": 1497, - "end": 1498, + "start": 4006, + "end": 4007, "loc": { "start": { - "line": 45, - "column": 26 + "line": 118, + "column": 36 }, "end": { - "line": 45, - "column": 27 + "line": 118, + "column": 37 } }, - "name": "U" + "name": "E" } } } @@ -4364,75 +13264,75 @@ }, { "type": "VariableDeclaration", - "start": 1591, - "end": 1615, + "start": 4014, + "end": 4039, "loc": { "start": { - "line": 48, + "line": 119, "column": 1 }, "end": { - "line": 48, - "column": 25 + "line": 119, + "column": 26 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1597, - "end": 1614, + "start": 4020, + "end": 4038, "loc": { "start": { - "line": 48, + "line": 119, "column": 7 }, "end": { - "line": 48, - "column": 24 + "line": 119, + "column": 25 } }, "id": { "type": "Identifier", - "start": 1597, - "end": 1599, + "start": 4020, + "end": 4023, "loc": { "start": { - "line": 48, + "line": 119, "column": 7 }, "end": { - "line": 48, - "column": 9 + "line": 119, + "column": 10 } }, - "name": "b8" + "name": "b29" }, "init": { "type": "CallExpression", - "start": 1602, - "end": 1614, + "start": 4026, + "end": 4038, "loc": { "start": { - "line": 48, - "column": 12 + "line": 119, + "column": 13 }, "end": { - "line": 48, - "column": 24 + "line": 119, + "column": 25 } }, "callee": { "type": "Identifier", - "start": 1602, - "end": 1604, + "start": 4026, + "end": 4028, "loc": { "start": { - "line": 48, - "column": 12 + "line": 119, + "column": 13 }, "end": { - "line": 48, - "column": 14 + "line": 119, + "column": 15 } }, "name": "fn" @@ -4440,201 +13340,205 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1604, - "end": 1612, + "start": 4028, + "end": 4036, "loc": { "start": { - "line": 48, - "column": 14 + "line": 119, + "column": 15 }, "end": { - "line": 48, - "column": 22 + "line": 119, + "column": 23 } }, "params": [ { - "type": "TSTupleType", - "start": 1605, - "end": 1611, + "type": "TSIndexedAccessType", + "start": 4029, + "end": 4035, "loc": { "start": { - "line": 48, - "column": 15 + "line": 119, + "column": 16 }, "end": { - "line": 48, - "column": 21 + "line": 119, + "column": 22 } }, - "elementTypes": [ - { - "type": "TSTypeReference", - "start": 1606, - "end": 1610, + "objectType": { + "type": "TSTypeReference", + "start": 4029, + "end": 4030, + "loc": { + "start": { + "line": 119, + "column": 16 + }, + "end": { + "line": 119, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4029, + "end": 4030, "loc": { "start": { - "line": 48, + "line": 119, "column": 16 }, "end": { - "line": 48, - "column": 20 + "line": 119, + "column": 17 } }, - "typeName": { + "name": "A" + } + }, + "indexType": { + "type": "TSTypeReference", + "start": 4031, + "end": 4034, + "loc": { + "start": { + "line": 119, + "column": 18 + }, + "end": { + "line": 119, + "column": 21 + } + }, + "typeName": { + "type": "TSQualifiedName", + "start": 4031, + "end": 4034, + "loc": { + "start": { + "line": 119, + "column": 18 + }, + "end": { + "line": 119, + "column": 21 + } + }, + "left": { "type": "Identifier", - "start": 1606, - "end": 1607, + "start": 4031, + "end": 4032, "loc": { "start": { - "line": 48, - "column": 16 + "line": 119, + "column": 18 }, "end": { - "line": 48, - "column": 17 + "line": 119, + "column": 19 } }, - "name": "T" + "name": "B" }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1607, - "end": 1610, + "right": { + "type": "Identifier", + "start": 4033, + "end": 4034, "loc": { "start": { - "line": 48, - "column": 17 + "line": 119, + "column": 20 }, "end": { - "line": 48, - "column": 20 + "line": 119, + "column": 21 } }, - "params": [ - { - "type": "TSTypeReference", - "start": 1608, - "end": 1609, - "loc": { - "start": { - "line": 48, - "column": 18 - }, - "end": { - "line": 48, - "column": 19 - } - }, - "typeName": { - "type": "Identifier", - "start": 1608, - "end": 1609, - "loc": { - "start": { - "line": 48, - "column": 18 - }, - "end": { - "line": 48, - "column": 19 - } - }, - "name": "A" - } - } - ] + "name": "C" } } - ] + } } ] } } } ], - "kind": "const", - "leadingComments": [ - { - "type": "Line", - "value": " a generic nested inside a tuple or object-type arg still parses as type arguments", - "start": 1505, - "end": 1589 - } - ] + "kind": "const" }, { "type": "VariableDeclaration", - "start": 1617, - "end": 1644, + "start": 4041, + "end": 4069, "loc": { "start": { - "line": 49, + "line": 120, "column": 1 }, "end": { - "line": 49, - "column": 28 + "line": 120, + "column": 29 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1623, - "end": 1643, + "start": 4047, + "end": 4068, "loc": { "start": { - "line": 49, + "line": 120, "column": 7 }, "end": { - "line": 49, - "column": 27 + "line": 120, + "column": 28 } }, "id": { "type": "Identifier", - "start": 1623, - "end": 1625, + "start": 4047, + "end": 4050, "loc": { "start": { - "line": 49, + "line": 120, "column": 7 }, "end": { - "line": 49, - "column": 9 + "line": 120, + "column": 10 } }, - "name": "b9" + "name": "b30" }, "init": { "type": "CallExpression", - "start": 1628, - "end": 1643, + "start": 4053, + "end": 4068, "loc": { "start": { - "line": 49, - "column": 12 + "line": 120, + "column": 13 }, "end": { - "line": 49, - "column": 27 + "line": 120, + "column": 28 } }, "callee": { "type": "Identifier", - "start": 1628, - "end": 1630, + "start": 4053, + "end": 4055, "loc": { "start": { - "line": 49, - "column": 12 + "line": 120, + "column": 13 }, "end": { - "line": 49, - "column": 14 + "line": 120, + "column": 15 } }, "name": "fn" @@ -4642,145 +13546,142 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1630, - "end": 1641, + "start": 4055, + "end": 4066, "loc": { "start": { - "line": 49, - "column": 14 + "line": 120, + "column": 15 }, "end": { - "line": 49, - "column": 25 + "line": 120, + "column": 26 } }, "params": [ { - "type": "TSTupleType", - "start": 1631, - "end": 1640, + "type": "TSIndexedAccessType", + "start": 4056, + "end": 4065, "loc": { "start": { - "line": 49, - "column": 15 + "line": 120, + "column": 16 }, "end": { - "line": 49, - "column": 24 + "line": 120, + "column": 25 } }, - "elementTypes": [ - { - "type": "TSTypeReference", - "start": 1632, - "end": 1633, + "objectType": { + "type": "TSTypeReference", + "start": 4056, + "end": 4057, + "loc": { + "start": { + "line": 120, + "column": 16 + }, + "end": { + "line": 120, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4056, + "end": 4057, "loc": { "start": { - "line": 49, + "line": 120, "column": 16 }, "end": { - "line": 49, + "line": 120, "column": 17 } }, - "typeName": { - "type": "Identifier", - "start": 1632, - "end": 1633, - "loc": { - "start": { - "line": 49, - "column": 16 - }, - "end": { - "line": 49, - "column": 17 - } - }, - "name": "A" + "name": "A" + } + }, + "indexType": { + "type": "TSIndexedAccessType", + "start": 4058, + "end": 4064, + "loc": { + "start": { + "line": 120, + "column": 18 + }, + "end": { + "line": 120, + "column": 24 } }, - { + "objectType": { "type": "TSTypeReference", - "start": 1635, - "end": 1639, + "start": 4058, + "end": 4059, "loc": { "start": { - "line": 49, - "column": 19 + "line": 120, + "column": 18 }, "end": { - "line": 49, - "column": 23 + "line": 120, + "column": 19 } }, "typeName": { "type": "Identifier", - "start": 1635, - "end": 1636, + "start": 4058, + "end": 4059, "loc": { "start": { - "line": 49, - "column": 19 + "line": 120, + "column": 18 }, "end": { - "line": 49, - "column": 20 + "line": 120, + "column": 19 } }, - "name": "T" + "name": "B" + } + }, + "indexType": { + "type": "TSLiteralType", + "start": 4060, + "end": 4063, + "loc": { + "start": { + "line": 120, + "column": 20 + }, + "end": { + "line": 120, + "column": 23 + } }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1636, - "end": 1639, + "literal": { + "type": "Literal", + "start": 4060, + "end": 4063, "loc": { "start": { - "line": 49, + "line": 120, "column": 20 }, "end": { - "line": 49, + "line": 120, "column": 23 } }, - "params": [ - { - "type": "TSTypeReference", - "start": 1637, - "end": 1638, - "loc": { - "start": { - "line": 49, - "column": 21 - }, - "end": { - "line": 49, - "column": 22 - } - }, - "typeName": { - "type": "Identifier", - "start": 1637, - "end": 1638, - "loc": { - "start": { - "line": 49, - "column": 21 - }, - "end": { - "line": 49, - "column": 22 - } - }, - "name": "B" - } - } - ] + "value": "k", + "raw": "'k'" } } - ] + } } ] } @@ -4791,74 +13692,74 @@ }, { "type": "VariableDeclaration", - "start": 1646, - "end": 1676, + "start": 4071, + "end": 4097, "loc": { "start": { - "line": 50, + "line": 121, "column": 1 }, "end": { - "line": 50, - "column": 31 + "line": 121, + "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1652, - "end": 1675, + "start": 4077, + "end": 4096, "loc": { "start": { - "line": 50, + "line": 121, "column": 7 }, "end": { - "line": 50, - "column": 30 + "line": 121, + "column": 26 } }, "id": { "type": "Identifier", - "start": 1652, - "end": 1655, + "start": 4077, + "end": 4080, "loc": { "start": { - "line": 50, + "line": 121, "column": 7 }, "end": { - "line": 50, + "line": 121, "column": 10 } }, - "name": "b10" + "name": "b31" }, "init": { "type": "CallExpression", - "start": 1658, - "end": 1675, + "start": 4083, + "end": 4096, "loc": { "start": { - "line": 50, + "line": 121, "column": 13 }, "end": { - "line": 50, - "column": 30 + "line": 121, + "column": 26 } }, "callee": { "type": "Identifier", - "start": 1658, - "end": 1660, + "start": 4083, + "end": 4085, "loc": { "start": { - "line": 50, + "line": 121, "column": 13 }, "end": { - "line": 50, + "line": 121, "column": 15 } }, @@ -4867,161 +13768,143 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1660, - "end": 1673, + "start": 4085, + "end": 4094, "loc": { "start": { - "line": 50, + "line": 121, "column": 15 }, "end": { - "line": 50, - "column": 28 + "line": 121, + "column": 24 } }, "params": [ { - "type": "TSTypeLiteral", - "start": 1661, - "end": 1672, + "type": "TSIndexedAccessType", + "start": 4086, + "end": 4093, "loc": { "start": { - "line": 50, + "line": 121, "column": 16 }, - "end": { - "line": 50, - "column": 27 + "end": { + "line": 121, + "column": 23 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 4086, + "end": 4087, + "loc": { + "start": { + "line": 121, + "column": 16 + }, + "end": { + "line": 121, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4086, + "end": 4087, + "loc": { + "start": { + "line": 121, + "column": 16 + }, + "end": { + "line": 121, + "column": 17 + } + }, + "name": "A" } }, - "members": [ - { - "type": "TSPropertySignature", - "start": 1663, - "end": 1670, + "indexType": { + "type": "TSTypeReference", + "start": 4088, + "end": 4092, + "loc": { + "start": { + "line": 121, + "column": 18 + }, + "end": { + "line": 121, + "column": 22 + } + }, + "typeName": { + "type": "Identifier", + "start": 4088, + "end": 4089, "loc": { "start": { - "line": 50, + "line": 121, "column": 18 }, "end": { - "line": 50, - "column": 25 + "line": 121, + "column": 19 } }, - "computed": false, - "key": { - "type": "Identifier", - "start": 1663, - "end": 1664, - "loc": { - "start": { - "line": 50, - "column": 18 - }, - "end": { - "line": 50, - "column": 19 - } + "name": "B" + }, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "start": 4089, + "end": 4092, + "loc": { + "start": { + "line": 121, + "column": 19 }, - "name": "a" + "end": { + "line": 121, + "column": 22 + } }, - "typeAnnotation": { - "type": "TSTypeAnnotation", - "start": 1664, - "end": 1670, - "loc": { - "start": { - "line": 50, - "column": 19 - }, - "end": { - "line": 50, - "column": 25 - } - }, - "typeAnnotation": { + "params": [ + { "type": "TSTypeReference", - "start": 1666, - "end": 1670, + "start": 4090, + "end": 4091, "loc": { "start": { - "line": 50, - "column": 21 + "line": 121, + "column": 20 }, "end": { - "line": 50, - "column": 25 + "line": 121, + "column": 21 } }, "typeName": { "type": "Identifier", - "start": 1666, - "end": 1667, - "loc": { - "start": { - "line": 50, - "column": 21 - }, - "end": { - "line": 50, - "column": 22 - } - }, - "name": "T" - }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1667, - "end": 1670, + "start": 4090, + "end": 4091, "loc": { "start": { - "line": 50, - "column": 22 + "line": 121, + "column": 20 }, "end": { - "line": 50, - "column": 25 + "line": 121, + "column": 21 } }, - "params": [ - { - "type": "TSTypeReference", - "start": 1668, - "end": 1669, - "loc": { - "start": { - "line": 50, - "column": 23 - }, - "end": { - "line": 50, - "column": 24 - } - }, - "typeName": { - "type": "Identifier", - "start": 1668, - "end": 1669, - "loc": { - "start": { - "line": 50, - "column": 23 - }, - "end": { - "line": 50, - "column": 24 - } - }, - "name": "B" - } - } - ] + "name": "C" } } - } + ] } - ] + } } ] } @@ -5032,74 +13915,74 @@ }, { "type": "VariableDeclaration", - "start": 1678, - "end": 1706, + "start": 4341, + "end": 4368, "loc": { "start": { - "line": 51, + "line": 126, "column": 1 }, "end": { - "line": 51, - "column": 29 + "line": 126, + "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1684, - "end": 1705, + "start": 4347, + "end": 4367, "loc": { "start": { - "line": 51, + "line": 126, "column": 7 }, "end": { - "line": 51, - "column": 28 + "line": 126, + "column": 27 } }, "id": { "type": "Identifier", - "start": 1684, - "end": 1687, + "start": 4347, + "end": 4350, "loc": { "start": { - "line": 51, + "line": 126, "column": 7 }, "end": { - "line": 51, + "line": 126, "column": 10 } }, - "name": "b11" + "name": "b32" }, "init": { "type": "CallExpression", - "start": 1690, - "end": 1705, + "start": 4353, + "end": 4367, "loc": { "start": { - "line": 51, + "line": 126, "column": 13 }, "end": { - "line": 51, - "column": 28 + "line": 126, + "column": 27 } }, "callee": { "type": "Identifier", - "start": 1690, - "end": 1692, + "start": 4353, + "end": 4355, "loc": { "start": { - "line": 51, + "line": 126, "column": 13 }, "end": { - "line": 51, + "line": 126, "column": 15 } }, @@ -5108,223 +13991,243 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1692, - "end": 1703, + "start": 4355, + "end": 4365, "loc": { "start": { - "line": 51, + "line": 126, "column": 15 }, "end": { - "line": 51, - "column": 26 + "line": 126, + "column": 25 } }, "params": [ { - "type": "TSTupleType", - "start": 1693, - "end": 1702, + "type": "TSIndexedAccessType", + "start": 4356, + "end": 4364, "loc": { "start": { - "line": 51, + "line": 126, "column": 16 }, "end": { - "line": 51, - "column": 25 + "line": 126, + "column": 24 } }, - "elementTypes": [ - { - "type": "TSTypeReference", - "start": 1694, - "end": 1701, + "objectType": { + "type": "TSTypeReference", + "start": 4356, + "end": 4357, + "loc": { + "start": { + "line": 126, + "column": 16 + }, + "end": { + "line": 126, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4356, + "end": 4357, "loc": { "start": { - "line": 51, - "column": 17 + "line": 126, + "column": 16 }, "end": { - "line": 51, - "column": 24 + "line": 126, + "column": 17 } }, - "typeName": { - "type": "Identifier", - "start": 1694, - "end": 1695, + "name": "A" + } + }, + "indexType": { + "type": "TSUnionType", + "start": 4358, + "end": 4363, + "loc": { + "start": { + "line": 126, + "column": 18 + }, + "end": { + "line": 126, + "column": 23 + } + }, + "types": [ + { + "type": "TSLiteralType", + "start": 4358, + "end": 4359, "loc": { "start": { - "line": 51, - "column": 17 + "line": 126, + "column": 18 }, "end": { - "line": 51, - "column": 18 + "line": 126, + "column": 19 } }, - "name": "T" + "literal": { + "type": "Literal", + "start": 4358, + "end": 4359, + "loc": { + "start": { + "line": 126, + "column": 18 + }, + "end": { + "line": 126, + "column": 19 + } + }, + "value": 0, + "raw": "0" + } }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1695, - "end": 1701, + { + "type": "TSLiteralType", + "start": 4362, + "end": 4363, "loc": { "start": { - "line": 51, - "column": 18 + "line": 126, + "column": 22 }, "end": { - "line": 51, - "column": 24 + "line": 126, + "column": 23 } }, - "params": [ - { - "type": "TSTypeReference", - "start": 1696, - "end": 1697, - "loc": { - "start": { - "line": 51, - "column": 19 - }, - "end": { - "line": 51, - "column": 20 - } + "literal": { + "type": "Literal", + "start": 4362, + "end": 4363, + "loc": { + "start": { + "line": 126, + "column": 22 }, - "typeName": { - "type": "Identifier", - "start": 1696, - "end": 1697, - "loc": { - "start": { - "line": 51, - "column": 19 - }, - "end": { - "line": 51, - "column": 20 - } - }, - "name": "A" + "end": { + "line": 126, + "column": 23 } }, - { - "type": "TSTypeReference", - "start": 1699, - "end": 1700, - "loc": { - "start": { - "line": 51, - "column": 22 - }, - "end": { - "line": 51, - "column": 23 - } - }, - "typeName": { - "type": "Identifier", - "start": 1699, - "end": 1700, - "loc": { - "start": { - "line": 51, - "column": 22 - }, - "end": { - "line": 51, - "column": 23 - } - }, - "name": "B" - } - } - ] + "value": 1, + "raw": "1" + } } - } - ] + ] + } } ] } } } ], - "kind": "const" + "kind": "const", + "leadingComments": [ + { + "type": "Line", + "value": " a numeric literal index continues into a type exactly as a reference index does —", + "start": 4100, + "end": 4184 + }, + { + "type": "Line", + "value": " union, intersection, and conditional forms are type arguments whichever operand", + "start": 4186, + "end": 4268 + }, + { + "type": "Line", + "value": " kind opens them, and an exponent's own sign belongs to the literal", + "start": 4270, + "end": 4339 + } + ] }, { "type": "VariableDeclaration", - "start": 1708, - "end": 1735, + "start": 4370, + "end": 4399, "loc": { "start": { - "line": 52, + "line": 127, "column": 1 }, "end": { - "line": 52, - "column": 28 + "line": 127, + "column": 30 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1714, - "end": 1734, + "start": 4376, + "end": 4398, "loc": { "start": { - "line": 52, + "line": 127, "column": 7 }, "end": { - "line": 52, - "column": 27 + "line": 127, + "column": 29 } }, "id": { "type": "Identifier", - "start": 1714, - "end": 1717, + "start": 4376, + "end": 4379, "loc": { "start": { - "line": 52, + "line": 127, "column": 7 }, "end": { - "line": 52, + "line": 127, "column": 10 } }, - "name": "b12" + "name": "b33" }, "init": { "type": "CallExpression", - "start": 1720, - "end": 1734, + "start": 4382, + "end": 4398, "loc": { "start": { - "line": 52, + "line": 127, "column": 13 }, "end": { - "line": 52, - "column": 27 + "line": 127, + "column": 29 } }, "callee": { "type": "Identifier", - "start": 1720, - "end": 1722, + "start": 4382, + "end": 4384, "loc": { "start": { - "line": 52, + "line": 127, "column": 13 }, "end": { - "line": 52, + "line": 127, "column": 15 } }, @@ -5333,129 +14236,179 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1722, - "end": 1732, + "start": 4384, + "end": 4396, "loc": { "start": { - "line": 52, + "line": 127, "column": 15 }, "end": { - "line": 52, - "column": 25 + "line": 127, + "column": 27 } }, "params": [ { - "type": "TSTupleType", - "start": 1723, - "end": 1731, + "type": "TSIndexedAccessType", + "start": 4385, + "end": 4395, "loc": { "start": { - "line": 52, + "line": 127, "column": 16 }, "end": { - "line": 52, - "column": 24 + "line": 127, + "column": 26 } }, - "elementTypes": [ - { - "type": "TSArrayType", - "start": 1724, - "end": 1730, + "objectType": { + "type": "TSTypeReference", + "start": 4385, + "end": 4386, + "loc": { + "start": { + "line": 127, + "column": 16 + }, + "end": { + "line": 127, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4385, + "end": 4386, "loc": { "start": { - "line": 52, - "column": 17 + "line": 127, + "column": 16 }, "end": { - "line": 52, - "column": 23 + "line": 127, + "column": 17 } }, - "elementType": { - "type": "TSTypeReference", - "start": 1724, - "end": 1728, + "name": "A" + } + }, + "indexType": { + "type": "TSUnionType", + "start": 4387, + "end": 4394, + "loc": { + "start": { + "line": 127, + "column": 18 + }, + "end": { + "line": 127, + "column": 25 + } + }, + "types": [ + { + "type": "TSLiteralType", + "start": 4387, + "end": 4389, "loc": { "start": { - "line": 52, - "column": 17 + "line": 127, + "column": 18 }, "end": { - "line": 52, - "column": 21 + "line": 127, + "column": 20 } }, - "typeName": { - "type": "Identifier", - "start": 1724, - "end": 1725, + "literal": { + "type": "UnaryExpression", + "start": 4387, + "end": 4389, "loc": { "start": { - "line": 52, - "column": 17 + "line": 127, + "column": 18 }, "end": { - "line": 52, - "column": 18 + "line": 127, + "column": 20 } }, - "name": "T" + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 4388, + "end": 4389, + "loc": { + "start": { + "line": 127, + "column": 19 + }, + "end": { + "line": 127, + "column": 20 + } + }, + "value": 1, + "raw": "1" + } + } + }, + { + "type": "TSLiteralType", + "start": 4392, + "end": 4394, + "loc": { + "start": { + "line": 127, + "column": 23 + }, + "end": { + "line": 127, + "column": 25 + } }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1725, - "end": 1728, + "literal": { + "type": "UnaryExpression", + "start": 4392, + "end": 4394, "loc": { "start": { - "line": 52, - "column": 18 + "line": 127, + "column": 23 }, "end": { - "line": 52, - "column": 21 + "line": 127, + "column": 25 } }, - "params": [ - { - "type": "TSTypeReference", - "start": 1726, - "end": 1727, - "loc": { - "start": { - "line": 52, - "column": 19 - }, - "end": { - "line": 52, - "column": 20 - } + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 4393, + "end": 4394, + "loc": { + "start": { + "line": 127, + "column": 24 }, - "typeName": { - "type": "Identifier", - "start": 1726, - "end": 1727, - "loc": { - "start": { - "line": 52, - "column": 19 - }, - "end": { - "line": 52, - "column": 20 - } - }, - "name": "A" + "end": { + "line": 127, + "column": 25 } - } - ] + }, + "value": 2, + "raw": "2" + } } } - } - ] + ] + } } ] } @@ -5466,74 +14419,74 @@ }, { "type": "VariableDeclaration", - "start": 1737, - "end": 1765, + "start": 4401, + "end": 4428, "loc": { "start": { - "line": 53, + "line": 128, "column": 1 }, "end": { - "line": 53, - "column": 29 + "line": 128, + "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1743, - "end": 1764, + "start": 4407, + "end": 4427, "loc": { "start": { - "line": 53, + "line": 128, "column": 7 }, "end": { - "line": 53, - "column": 28 + "line": 128, + "column": 27 } }, "id": { "type": "Identifier", - "start": 1743, - "end": 1746, + "start": 4407, + "end": 4410, "loc": { "start": { - "line": 53, + "line": 128, "column": 7 }, "end": { - "line": 53, + "line": 128, "column": 10 } }, - "name": "b13" + "name": "b34" }, "init": { "type": "CallExpression", - "start": 1749, - "end": 1764, + "start": 4413, + "end": 4427, "loc": { "start": { - "line": 53, + "line": 128, "column": 13 }, "end": { - "line": 53, - "column": 28 + "line": 128, + "column": 27 } }, "callee": { "type": "Identifier", - "start": 1749, - "end": 1751, + "start": 4413, + "end": 4415, "loc": { "start": { - "line": 53, + "line": 128, "column": 13 }, "end": { - "line": 53, + "line": 128, "column": 15 } }, @@ -5542,144 +14495,144 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1751, - "end": 1762, + "start": 4415, + "end": 4425, "loc": { "start": { - "line": 53, + "line": 128, "column": 15 }, "end": { - "line": 53, - "column": 26 + "line": 128, + "column": 25 } }, "params": [ { - "type": "TSTupleType", - "start": 1752, - "end": 1758, + "type": "TSIndexedAccessType", + "start": 4416, + "end": 4424, "loc": { "start": { - "line": 53, + "line": 128, "column": 16 }, "end": { - "line": 53, - "column": 22 + "line": 128, + "column": 24 } }, - "elementTypes": [ - { - "type": "TSTypeReference", - "start": 1753, - "end": 1757, + "objectType": { + "type": "TSTypeReference", + "start": 4416, + "end": 4417, + "loc": { + "start": { + "line": 128, + "column": 16 + }, + "end": { + "line": 128, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4416, + "end": 4417, "loc": { "start": { - "line": 53, - "column": 17 + "line": 128, + "column": 16 }, "end": { - "line": 53, - "column": 21 + "line": 128, + "column": 17 } }, - "typeName": { - "type": "Identifier", - "start": 1753, - "end": 1754, + "name": "A" + } + }, + "indexType": { + "type": "TSIntersectionType", + "start": 4418, + "end": 4423, + "loc": { + "start": { + "line": 128, + "column": 18 + }, + "end": { + "line": 128, + "column": 23 + } + }, + "types": [ + { + "type": "TSLiteralType", + "start": 4418, + "end": 4419, "loc": { "start": { - "line": 53, - "column": 17 + "line": 128, + "column": 18 }, "end": { - "line": 53, - "column": 18 + "line": 128, + "column": 19 } }, - "name": "T" + "literal": { + "type": "Literal", + "start": 4418, + "end": 4419, + "loc": { + "start": { + "line": 128, + "column": 18 + }, + "end": { + "line": 128, + "column": 19 + } + }, + "value": 0, + "raw": "0" + } }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1754, - "end": 1757, + { + "type": "TSLiteralType", + "start": 4422, + "end": 4423, "loc": { "start": { - "line": 53, - "column": 18 + "line": 128, + "column": 22 }, "end": { - "line": 53, - "column": 21 + "line": 128, + "column": 23 } }, - "params": [ - { - "type": "TSTypeReference", - "start": 1755, - "end": 1756, - "loc": { - "start": { - "line": 53, - "column": 19 - }, - "end": { - "line": 53, - "column": 20 - } + "literal": { + "type": "Literal", + "start": 4422, + "end": 4423, + "loc": { + "start": { + "line": 128, + "column": 22 }, - "typeName": { - "type": "Identifier", - "start": 1755, - "end": 1756, - "loc": { - "start": { - "line": 53, - "column": 19 - }, - "end": { - "line": 53, - "column": 20 - } - }, - "name": "A" + "end": { + "line": 128, + "column": 23 } - } - ] - } - } - ] - }, - { - "type": "TSTypeReference", - "start": 1760, - "end": 1761, - "loc": { - "start": { - "line": 53, - "column": 24 - }, - "end": { - "line": 53, - "column": 25 - } - }, - "typeName": { - "type": "Identifier", - "start": 1760, - "end": 1761, - "loc": { - "start": { - "line": 53, - "column": 24 - }, - "end": { - "line": 53, - "column": 25 + }, + "value": 1, + "raw": "1" + } } - }, - "name": "B" + ] } } ] @@ -5691,74 +14644,74 @@ }, { "type": "VariableDeclaration", - "start": 1767, - "end": 1794, + "start": 4430, + "end": 4460, "loc": { "start": { - "line": 54, + "line": 129, "column": 1 }, "end": { - "line": 54, - "column": 28 + "line": 129, + "column": 31 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1773, - "end": 1793, + "start": 4436, + "end": 4459, "loc": { "start": { - "line": 54, + "line": 129, "column": 7 }, "end": { - "line": 54, - "column": 27 + "line": 129, + "column": 30 } }, "id": { "type": "Identifier", - "start": 1773, - "end": 1776, + "start": 4436, + "end": 4439, "loc": { "start": { - "line": 54, + "line": 129, "column": 7 }, "end": { - "line": 54, + "line": 129, "column": 10 } }, - "name": "b14" + "name": "b35" }, "init": { "type": "CallExpression", - "start": 1779, - "end": 1793, + "start": 4442, + "end": 4459, "loc": { "start": { - "line": 54, + "line": 129, "column": 13 }, "end": { - "line": 54, - "column": 27 + "line": 129, + "column": 30 } }, "callee": { "type": "Identifier", - "start": 1779, - "end": 1781, + "start": 4442, + "end": 4444, "loc": { "start": { - "line": 54, + "line": 129, "column": 13 }, "end": { - "line": 54, + "line": 129, "column": 15 } }, @@ -5767,131 +14720,145 @@ "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1781, - "end": 1791, + "start": 4444, + "end": 4457, "loc": { "start": { - "line": 54, + "line": 129, "column": 15 }, "end": { - "line": 54, - "column": 25 + "line": 129, + "column": 28 } }, "params": [ { - "type": "TSTupleType", - "start": 1782, - "end": 1790, + "type": "TSIndexedAccessType", + "start": 4445, + "end": 4456, "loc": { "start": { - "line": 54, + "line": 129, "column": 16 }, "end": { - "line": 54, - "column": 24 + "line": 129, + "column": 27 } }, - "elementTypes": [ - { - "type": "TSTupleType", - "start": 1783, - "end": 1789, + "objectType": { + "type": "TSTypeReference", + "start": 4445, + "end": 4446, + "loc": { + "start": { + "line": 129, + "column": 16 + }, + "end": { + "line": 129, + "column": 17 + } + }, + "typeName": { + "type": "Identifier", + "start": 4445, + "end": 4446, "loc": { "start": { - "line": 54, - "column": 17 + "line": 129, + "column": 16 }, "end": { - "line": 54, - "column": 23 + "line": 129, + "column": 17 } }, - "elementTypes": [ - { - "type": "TSTypeReference", - "start": 1784, - "end": 1788, + "name": "A" + } + }, + "indexType": { + "type": "TSUnionType", + "start": 4447, + "end": 4455, + "loc": { + "start": { + "line": 129, + "column": 18 + }, + "end": { + "line": 129, + "column": 26 + } + }, + "types": [ + { + "type": "TSLiteralType", + "start": 4447, + "end": 4451, + "loc": { + "start": { + "line": 129, + "column": 18 + }, + "end": { + "line": 129, + "column": 22 + } + }, + "literal": { + "type": "Literal", + "start": 4447, + "end": 4451, "loc": { "start": { - "line": 54, + "line": 129, "column": 18 }, "end": { - "line": 54, + "line": 129, "column": 22 } }, - "typeName": { - "type": "Identifier", - "start": 1784, - "end": 1785, - "loc": { - "start": { - "line": 54, - "column": 18 - }, - "end": { - "line": 54, - "column": 19 - } - }, - "name": "T" + "value": 0.001, + "raw": "1e-3" + } + }, + { + "type": "TSLiteralType", + "start": 4454, + "end": 4455, + "loc": { + "start": { + "line": 129, + "column": 25 }, - "typeArguments": { - "type": "TSTypeParameterInstantiation", - "start": 1785, - "end": 1788, - "loc": { - "start": { - "line": 54, - "column": 19 - }, - "end": { - "line": 54, - "column": 22 - } - }, - "params": [ - { - "type": "TSTypeReference", - "start": 1786, - "end": 1787, - "loc": { - "start": { - "line": 54, - "column": 20 - }, - "end": { - "line": 54, - "column": 21 - } - }, - "typeName": { - "type": "Identifier", - "start": 1786, - "end": 1787, - "loc": { - "start": { - "line": 54, - "column": 20 - }, - "end": { - "line": 54, - "column": 21 - } - }, - "name": "A" - } - } - ] + "end": { + "line": 129, + "column": 26 } + }, + "literal": { + "type": "Literal", + "start": 4454, + "end": 4455, + "loc": { + "start": { + "line": 129, + "column": 25 + }, + "end": { + "line": 129, + "column": 26 + } + }, + "value": 2, + "raw": "2" } - ] - } - ] + } + ] + } } ] } @@ -5902,161 +14869,280 @@ }, { "type": "VariableDeclaration", - "start": 1906, - "end": 1927, + "start": 4462, + "end": 4503, "loc": { "start": { - "line": 58, + "line": 130, "column": 1 }, "end": { - "line": 58, - "column": 22 + "line": 130, + "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", - "start": 1912, - "end": 1926, + "start": 4468, + "end": 4502, "loc": { "start": { - "line": 58, + "line": 130, "column": 7 }, "end": { - "line": 58, - "column": 21 + "line": 130, + "column": 41 } }, "id": { "type": "Identifier", - "start": 1912, - "end": 1915, + "start": 4468, + "end": 4471, "loc": { "start": { - "line": 58, + "line": 130, "column": 7 }, "end": { - "line": 58, + "line": 130, "column": 10 } }, - "name": "b15" + "name": "b36" }, "init": { - "type": "TaggedTemplateExpression", - "start": 1918, - "end": 1926, + "type": "CallExpression", + "start": 4474, + "end": 4502, "loc": { "start": { - "line": 58, + "line": 130, "column": 13 }, "end": { - "line": 58, - "column": 21 + "line": 130, + "column": 41 } }, - "tag": { + "callee": { "type": "Identifier", - "start": 1918, - "end": 1920, + "start": 4474, + "end": 4476, "loc": { "start": { - "line": 58, + "line": 130, "column": 13 }, "end": { - "line": 58, + "line": 130, "column": 15 } }, "name": "fn" }, - "quasi": { - "type": "TemplateLiteral", - "start": 1923, - "end": 1926, - "loc": { - "start": { - "line": 58, - "column": 18 - }, - "end": { - "line": 58, - "column": 21 - } - }, - "expressions": [], - "quasis": [ - { - "type": "TemplateElement", - "start": 1924, - "end": 1925, - "loc": { - "start": { - "line": 58, - "column": 19 - }, - "end": { - "line": 58, - "column": 20 - } - }, - "value": { - "raw": "b", - "cooked": "b" - }, - "tail": true - } - ] - }, + "arguments": [], "typeArguments": { "type": "TSTypeParameterInstantiation", - "start": 1920, - "end": 1923, + "start": 4476, + "end": 4500, "loc": { "start": { - "line": 58, + "line": 130, "column": 15 }, "end": { - "line": 58, - "column": 18 + "line": 130, + "column": 39 } }, "params": [ { - "type": "TSTypeReference", - "start": 1921, - "end": 1922, + "type": "TSIndexedAccessType", + "start": 4477, + "end": 4499, "loc": { "start": { - "line": 58, + "line": 130, "column": 16 }, "end": { - "line": 58, - "column": 17 + "line": 130, + "column": 38 } }, - "typeName": { - "type": "Identifier", - "start": 1921, - "end": 1922, + "objectType": { + "type": "TSTypeReference", + "start": 4477, + "end": 4478, "loc": { "start": { - "line": 58, + "line": 130, "column": 16 }, "end": { - "line": 58, + "line": 130, "column": 17 } }, - "name": "A" + "typeName": { + "type": "Identifier", + "start": 4477, + "end": 4478, + "loc": { + "start": { + "line": 130, + "column": 16 + }, + "end": { + "line": 130, + "column": 17 + } + }, + "name": "A" + } + }, + "indexType": { + "type": "TSConditionalType", + "start": 4479, + "end": 4498, + "loc": { + "start": { + "line": 130, + "column": 18 + }, + "end": { + "line": 130, + "column": 37 + } + }, + "checkType": { + "type": "TSLiteralType", + "start": 4479, + "end": 4480, + "loc": { + "start": { + "line": 130, + "column": 18 + }, + "end": { + "line": 130, + "column": 19 + } + }, + "literal": { + "type": "Literal", + "start": 4479, + "end": 4480, + "loc": { + "start": { + "line": 130, + "column": 18 + }, + "end": { + "line": 130, + "column": 19 + } + }, + "value": 0, + "raw": "0" + } + }, + "extendsType": { + "type": "TSLiteralType", + "start": 4489, + "end": 4490, + "loc": { + "start": { + "line": 130, + "column": 28 + }, + "end": { + "line": 130, + "column": 29 + } + }, + "literal": { + "type": "Literal", + "start": 4489, + "end": 4490, + "loc": { + "start": { + "line": 130, + "column": 28 + }, + "end": { + "line": 130, + "column": 29 + } + }, + "value": 1, + "raw": "1" + } + }, + "trueType": { + "type": "TSTypeReference", + "start": 4493, + "end": 4494, + "loc": { + "start": { + "line": 130, + "column": 32 + }, + "end": { + "line": 130, + "column": 33 + } + }, + "typeName": { + "type": "Identifier", + "start": 4493, + "end": 4494, + "loc": { + "start": { + "line": 130, + "column": 32 + }, + "end": { + "line": 130, + "column": 33 + } + }, + "name": "B" + } + }, + "falseType": { + "type": "TSTypeReference", + "start": 4497, + "end": 4498, + "loc": { + "start": { + "line": 130, + "column": 36 + }, + "end": { + "line": 130, + "column": 37 + } + }, + "typeName": { + "type": "Identifier", + "start": 4497, + "end": 4498, + "loc": { + "start": { + "line": 130, + "column": 36 + }, + "end": { + "line": 130, + "column": 37 + } + }, + "name": "C" + } + } } } ] @@ -6064,21 +15150,7 @@ } } ], - "kind": "const", - "leadingComments": [ - { - "type": "Line", - "value": " a template literal after the closing `>` is a tagged template on the", - "start": 1797, - "end": 1868 - }, - { - "type": "Line", - "value": " instantiation, not a comparison", - "start": 1870, - "end": 1904 - } - ] + "kind": "const" } ], "sourceType": "module" diff --git a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input.svelte b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input.svelte index a51066c67..e2fb9c295 100644 --- a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input.svelte +++ b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input.svelte @@ -34,6 +34,47 @@ const a21 = x < y > { a: 1 }; const a22 = x < y > typeof c; + // an indexed member access after `<` is a comparison operand, not an indexed access + // type; the `,` that follows it belongs to the enclosing argument, element, or + // property list, whatever the index is + fn(a < B[c], d); + fn(a < B['k'], d); + fn(a < B[typeof c], d); + const a23 = [a < B[c], d]; + const a24 = { a: b < C[d], e: f }; + const a25 = (a < B[c], d); + const a26 = a < B.C[d]; + const a27 = a < B[c][e]; + + // richer index contents are comparison operands too when no `>` closes the list + fn(a < B[c | d], e); + fn(a < B[c & d], e); + fn(a < B[c[d]], e); + fn(a < B[0], e); + fn(a < B[-1], e); + fn(a < B[c.d], e); + fn(a < B[c['k']], e); + fn(a < B[c < d], e); + + // arithmetic inside the index is not a type, so the list stays a comparison even + // when a `>` closes it; a negated operand and the logical and relational operators + // are expressions too, never types + const a32 = a < arr[b - 1] > c; + const a33 = a < arr[-b] > c; + const a34 = a < B[0 || 1] > c; + const a35 = a < B[0 <= 1] > c; + + // a `>` or a shift operator after the indexed operand continues the comparison + // chain — the `>` run belongs to the operator, not to a type-argument close + const a28 = a < B[c] > d; + const a29 = a < B[c] >> d; + const a30 = a < B[c] >>> d; + + // an identifier that merely starts with `extends` is a fresh statement on the next + // line (ASI), not a type constraint + const a31 = a < b; + extendsFoo(); + // genuine instantiation with a literal/keyword/object/tuple/numeric type arg, or a // function type with an optional param, still parses as type arguments const b1 = fn<'b'>(); @@ -56,4 +97,35 @@ // a template literal after the closing `>` is a tagged template on the // instantiation, not a comparison const b15 = fn`b`; + + // an indexed access, array, or conditional type argument still parses as type + // arguments — the closing `>` is followed by a call + const b16 = fn(); + const b17 = fn(); + const b18 = fn(); + const b19 = fn(); + const b20 = fn(); + const b21 = fn(); + const b22 = fn(); + + // every index content that is itself a valid type — union, intersection, nested + // index, numeric literal, and conditional — makes the list type arguments + const b23 = fn(); + const b24 = fn(); + const b25 = fn(); + const b26 = fn(); + const b27 = fn(); + const b28 = fn(); + const b29 = fn(); + const b30 = fn(); + const b31 = fn]>(); + + // a numeric literal index continues into a type exactly as a reference index does — + // union, intersection, and conditional forms are type arguments whichever operand + // kind opens them, and an exponent's own sign belongs to the literal + const b32 = fn(); + const b33 = fn(); + const b34 = fn(); + const b35 = fn(); + const b36 = fn(); diff --git a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input_invalid_empty_index_operand.svelte b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input_invalid_empty_index_operand.svelte new file mode 100644 index 000000000..1dde337f0 --- /dev/null +++ b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input_invalid_empty_index_operand.svelte @@ -0,0 +1,3 @@ + diff --git a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input_invalid_keyof_index_operand.svelte b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input_invalid_keyof_index_operand.svelte new file mode 100644 index 000000000..c150e05c0 --- /dev/null +++ b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/input_invalid_keyof_index_operand.svelte @@ -0,0 +1,3 @@ + diff --git a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_asi.svelte b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_asi.svelte new file mode 100644 index 000000000..ed95335fd --- /dev/null +++ b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_asi.svelte @@ -0,0 +1,131 @@ + diff --git a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_compact.svelte b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_compact.svelte index cdcc45f8a..135f6916e 100644 --- a/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_compact.svelte +++ b/tests/fixtures/typescript/expressions/binary/relational_lt_vs_type_args/unformatted_compact.svelte @@ -34,6 +34,47 @@ const a21=x{a:1}; const a22=xtypeof c; + // an indexed member access after `<` is a comparison operand, not an indexed access + // type; the `,` that follows it belongs to the enclosing argument, element, or + // property list, whatever the index is + fn(a` closes the list + fn(a` closes it; a negated operand and the logical and relational operators + // are expressions too, never types + const a32=a(c); + const a33=a(c); + const a34=a(c); + const a35=a(c); + + // a `>` or a shift operator after the indexed operand continues the comparison + // chain — the `>` run belongs to the operator, not to a type-argument close + const a28=ad; + const a29=a>d; + const a30=a>>d; + + // an identifier that merely starts with `extends` is a fresh statement on the next + // line (ASI), not a type constraint + const a31=a(); @@ -56,4 +97,35 @@ // a template literal after the closing `>` is a tagged template on the // instantiation, not a comparison const b15=fn`b`; + + // an indexed access, array, or conditional type argument still parses as type + // arguments — the closing `>` is followed by a call + const b16=fn(); + const b17=fn(); + const b18=fn(); + const b19=fn(); + const b20=fn(); + const b21=fn(); + const b22=fn(); + + // every index content that is itself a valid type — union, intersection, nested + // index, numeric literal, and conditional — makes the list type arguments + const b23=fn(); + const b24=fn(); + const b25=fn(); + const b26=fn(); + const b27=fn(); + const b28=fn(); + const b29=fn(); + const b30=fn(); + const b31=fn]>(); + + // a numeric literal index continues into a type exactly as a reference index does — + // union, intersection, and conditional forms are type arguments whichever operand + // kind opens them, and an exponent's own sign belongs to the literal + const b32=fn(); + const b33=fn(); + const b34=fn(); + const b35=fn(); + const b36=fn(); diff --git a/tests/fixtures/typescript/expressions/unary/update_operator_comment/expected.json b/tests/fixtures/typescript/expressions/unary/update_operator_comment/expected.json new file mode 100644 index 000000000..6c4accf31 --- /dev/null +++ b/tests/fixtures/typescript/expressions/unary/update_operator_comment/expected.json @@ -0,0 +1,601 @@ +{ + "css": null, + "js": [], + "start": 0, + "end": 394, + "type": "Root", + "fragment": { + "type": "Fragment", + "nodes": [] + }, + "options": null, + "comments": [ + { + "type": "Line", + "value": " a line comment between a prefix operator and its operand stays glued to the operator", + "start": 10, + "end": 97, + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 88 + } + } + }, + { + "type": "Line", + "value": " c1", + "start": 101, + "end": 106, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Line", + "value": " an own-line block comment does too", + "start": 113, + "end": 150, + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 38 + } + } + }, + { + "type": "Block", + "value": " c2 ", + "start": 154, + "end": 162, + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + { + "type": "Line", + "value": " a block comment glued to the operator leads the operand inline", + "start": 169, + "end": 234, + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 66 + } + } + }, + { + "type": "Block", + "value": " c3 ", + "start": 238, + "end": 246, + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + { + "type": "Line", + "value": " on the postfix side the comment trails the operand and glues to the operator", + "start": 252, + "end": 331, + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 80 + } + } + }, + { + "type": "Block", + "value": " c4 ", + "start": 335, + "end": 343, + "loc": { + "start": { + "line": 14, + "column": 3 + }, + "end": { + "line": 14, + "column": 11 + } + } + }, + { + "type": "Block", + "value": " c5 ", + "start": 351, + "end": 359, + "loc": { + "start": { + "line": 16, + "column": 3 + }, + "end": { + "line": 16, + "column": 11 + } + } + }, + { + "type": "Block", + "value": " c6 ", + "start": 372, + "end": 380, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 16 + } + } + } + ], + "instance": { + "type": "Script", + "start": 0, + "end": 393, + "context": "default", + "content": { + "type": "Program", + "start": 8, + "end": 384, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 99, + "end": 110, + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 99, + "end": 109, + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 108, + "end": 109, + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "name": "x", + "leadingComments": [ + { + "type": "Line", + "value": " c1", + "start": 101, + "end": 106 + } + ] + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " a line comment between a prefix operator and its operand stays glued to the operator", + "start": 10, + "end": 97 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 152, + "end": 166, + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 8, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 152, + "end": 165, + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 164, + "end": 165, + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "name": "y", + "leadingComments": [ + { + "type": "Block", + "value": " c2 ", + "start": 154, + "end": 162 + } + ] + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " an own-line block comment does too", + "start": 113, + "end": 150 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 236, + "end": 249, + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 14 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 236, + "end": 248, + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 13 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 247, + "end": 248, + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 13 + } + }, + "name": "z", + "leadingComments": [ + { + "type": "Block", + "value": " c3 ", + "start": 238, + "end": 246 + } + ] + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " a block comment glued to the operator leads the operand inline", + "start": 169, + "end": 234 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 333, + "end": 346, + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 14 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 333, + "end": 345, + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 13 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 333, + "end": 334, + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "name": "a", + "trailingComments": [ + { + "type": "Block", + "value": " c4 ", + "start": 335, + "end": 343 + } + ] + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " on the postfix side the comment trails the operand and glues to the operator", + "start": 252, + "end": 331 + } + ] + }, + { + "type": "ExpressionStatement", + "start": 349, + "end": 362, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 14 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 349, + "end": 361, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 13 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 349, + "end": 350, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 2 + } + }, + "name": "b", + "trailingComments": [ + { + "type": "Block", + "value": " c5 ", + "start": 351, + "end": 359 + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 365, + "end": 383, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 19 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 365, + "end": 382, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 18 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "MemberExpression", + "start": 365, + "end": 371, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 7 + } + }, + "object": { + "type": "Identifier", + "start": 365, + "end": 368, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 4 + } + }, + "name": "arr" + }, + "property": { + "type": "Literal", + "start": 369, + "end": 370, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + }, + "value": 0, + "raw": "0" + }, + "computed": true, + "optional": false, + "trailingComments": [ + { + "type": "Block", + "value": " c6 ", + "start": 372, + "end": 380 + } + ] + } + } + } + ], + "sourceType": "module" + }, + "attributes": [] + } +} diff --git a/tests/fixtures/typescript/expressions/unary/update_operator_comment/input.svelte b/tests/fixtures/typescript/expressions/unary/update_operator_comment/input.svelte new file mode 100644 index 000000000..c449abff3 --- /dev/null +++ b/tests/fixtures/typescript/expressions/unary/update_operator_comment/input.svelte @@ -0,0 +1,19 @@ + diff --git a/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/README.md b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/README.md new file mode 100644 index 000000000..435840d05 --- /dev/null +++ b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/README.md @@ -0,0 +1,29 @@ +# Negative literal type sign comment divergence + +A comment between a negative literal type's `-` and its numeral. Prettier wraps the +numeral in parens to hold the comment, producing output that **fails to re-parse**: + +- `type A = -/* c */ 1;` → `type A = -(/* c */ 1);` +- Union member: `-1 | -/* c */ 2` → `-1 | -(/* c */ 2)` +- Indexed-access index: `D[-/* c */ 1]` → `D[-(/* c */ 1)]` +- BigInt: `-/* c */ 1n` → `-(/* c */ 1n)` + +tsv keeps the comment where the author wrote it, between the sign and the numeral. + +## Reason + +Prettier bug. A parenthesized operand is valid after a *value*-position unary minus, +so prettier reuses that comment-holding trick in type position — but there is no such +type. TypeScript reads `-` as a negative literal type only when the very next token is +a numeric or bigint literal (`parseNonArrayType`: `lookAhead(nextTokenIsNumericOrBigIntLiteral) +? parseLiteralTypeNode(true) : parseTypeReference()`), and the neighbouring comment in +tsc's own parser spells out the intent — "We don't want to consider things like '(1)' +a type." A `(` fails that lookahead, so prettier's output is rejected by tsc, +acorn-typescript, and Svelte's parser alike. + +Preserving in place is what keeps tsv's output valid: `nextToken()` skips trivia, so a +comment between the sign and the numeral does not break the lookahead the way a paren +does. Without preservation the comment was dropped entirely (content loss) — the +position has no other emitter. + +See [conformance_prettier.md §Comment relocation](../../../../../docs/conformance_prettier.md#comment-relocation). diff --git a/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/expected.json b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/expected.json new file mode 100644 index 000000000..690a497cc --- /dev/null +++ b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/expected.json @@ -0,0 +1,596 @@ +{ + "css": null, + "js": [], + "start": 0, + "end": 126, + "type": "Root", + "fragment": { + "type": "Fragment", + "nodes": [] + }, + "options": null, + "comments": [ + { + "type": "Block", + "value": " c ", + "start": 30, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + { + "type": "Block", + "value": " c ", + "start": 57, + "end": 64, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 23 + } + } + }, + { + "type": "Block", + "value": " c ", + "start": 81, + "end": 88, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 20 + } + } + }, + { + "type": "Block", + "value": " c ", + "start": 104, + "end": 111, + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + ], + "instance": { + "type": "Script", + "start": 0, + "end": 125, + "context": "default", + "content": { + "type": "Program", + "start": 18, + "end": 116, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 20, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSLiteralType", + "start": 29, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "literal": { + "type": "UnaryExpression", + "start": 29, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": 1, + "raw": "1", + "leadingComments": [ + { + "type": "Block", + "value": " c ", + "start": 30, + "end": 37 + } + ] + } + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "start": 42, + "end": 67, + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "name": "B" + }, + "typeAnnotation": { + "type": "TSUnionType", + "start": 51, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "types": [ + { + "type": "TSLiteralType", + "start": 51, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "literal": { + "type": "UnaryExpression", + "start": 51, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "value": 1, + "raw": "1" + } + } + }, + { + "type": "TSLiteralType", + "start": 56, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "literal": { + "type": "UnaryExpression", + "start": 56, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 65, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "value": 2, + "raw": "2", + "leadingComments": [ + { + "type": "Block", + "value": " c ", + "start": 57, + "end": 64 + } + ] + } + } + } + ] + } + }, + { + "type": "TSTypeAliasDeclaration", + "start": 69, + "end": 92, + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 74, + "end": 75, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "name": "C" + }, + "typeAnnotation": { + "type": "TSIndexedAccessType", + "start": 78, + "end": 91, + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "objectType": { + "type": "TSTypeReference", + "start": 78, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "typeName": { + "type": "Identifier", + "start": 78, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "name": "D" + } + }, + "indexType": { + "type": "TSLiteralType", + "start": 80, + "end": 90, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "literal": { + "type": "UnaryExpression", + "start": 80, + "end": 90, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 89, + "end": 90, + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "value": 1, + "raw": "1", + "leadingComments": [ + { + "type": "Block", + "value": " c ", + "start": 81, + "end": 88 + } + ] + } + } + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "start": 94, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 99, + "end": 100, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "name": "E" + }, + "typeAnnotation": { + "type": "TSLiteralType", + "start": 103, + "end": 114, + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "literal": { + "type": "UnaryExpression", + "start": 103, + "end": 114, + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "Literal", + "start": 112, + "end": 114, + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "value": "1", + "raw": "1n", + "bigint": "1", + "leadingComments": [ + { + "type": "Block", + "value": " c ", + "start": 104, + "end": 111 + } + ] + } + } + } + } + ], + "sourceType": "module" + }, + "attributes": [ + { + "type": "Attribute", + "start": 8, + "end": 17, + "name": "lang", + "name_loc": { + "start": { + "line": 1, + "column": 8, + "character": 8 + }, + "end": { + "line": 1, + "column": 12, + "character": 12 + } + }, + "value": [ + { + "start": 14, + "end": 16, + "type": "Text", + "raw": "ts", + "data": "ts" + } + ] + } + ] + } +} diff --git a/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/input.svelte b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/input.svelte new file mode 100644 index 000000000..35ef54400 --- /dev/null +++ b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/input.svelte @@ -0,0 +1,6 @@ + diff --git a/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/output_prettier.svelte b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/output_prettier.svelte new file mode 100644 index 000000000..f2b87f61b --- /dev/null +++ b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/output_prettier.svelte @@ -0,0 +1,6 @@ + diff --git a/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/unformatted_ours_compact.svelte b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/unformatted_ours_compact.svelte new file mode 100644 index 000000000..1b0d2b1f0 --- /dev/null +++ b/tests/fixtures/typescript/types/negative_literal_sign_comment_prettier_divergence/unformatted_ours_compact.svelte @@ -0,0 +1,6 @@ +