From 737d31d5a985c4fc986e4e7a19ea756d19fcb0b0 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 21 Dec 2024 19:12:54 +0100 Subject: [PATCH] [JavaScript] Fix const arrow functions in TSX (#4114) --- JavaScript/JSX.sublime-syntax | 127 +++++++------- JavaScript/JavaScript.sublime-syntax | 17 +- JavaScript/TSX.sublime-syntax | 48 +++--- JavaScript/TypeScript.sublime-syntax | 192 ++++++++++----------- JavaScript/tests/syntax_test_jsx.jsx | 40 ++++- JavaScript/tests/syntax_test_tsx.tsx | 78 +++++++++ JavaScript/tests/syntax_test_typescript.ts | 137 ++++++++++++++- 7 files changed, 431 insertions(+), 208 deletions(-) diff --git a/JavaScript/JSX.sublime-syntax b/JavaScript/JSX.sublime-syntax index 4f9b8fb9be..eccf5e0b1d 100644 --- a/JavaScript/JSX.sublime-syntax +++ b/JavaScript/JSX.sublime-syntax @@ -24,7 +24,7 @@ variables: contexts: expression-begin: - meta_prepend: true - - include: jsx-tag-hack + - include: jsx-tag jsx-interpolation: - match: (?={/\*) @@ -66,97 +66,103 @@ contexts: pop: 1 - include: expressions - jsx-expect-tag-end: - - meta_content_scope: meta.tag.js - - match: '>{2,}' # ignore invalid punctuation - - match: '>' - scope: meta.tag.js punctuation.definition.tag.end.js - pop: 1 - - include: else-pop - jsx-meta: - meta_include_prototype: false - meta_scope: meta.jsx.js - include: immediately-pop jsx-tag: - - match: '<(?=\s*[/>{{jsx_tag_name_start}}])' + - match: <(?=\s*[/>{{jsx_tag_name_start}}]) scope: punctuation.definition.tag.begin.js set: - jsx-meta - - jsx-tag-attributes-top - - jsx-tag-hack: # Ugly hack so that TSX can un-include this in expression-begin - - include: jsx-tag + - jsx-tag-begin - jsx-tag-attributes-top: + jsx-tag-begin: - meta_include_prototype: false - meta_scope: meta.tag.js - - match: '/' + - match: / scope: punctuation.definition.tag.begin.js set: - - jsx-meta-unmatched-tag - - jsx-expect-tag-end + - jsx-expect-unmatched-tag-end - jsx-tag-name - - match: (?=\S) set: - jsx-tag-attributes - jsx-tag-name - jsx-meta-unmatched-tag: + jsx-expect-unmatched-tag-end: - meta_include_prototype: false - meta_scope: invalid.illegal.unmatched-tag.js - - include: immediately-pop + - meta_content_scope: meta.tag.js + - include: jsx-expect-tag-end + + jsx-child-tag: + - match: <(?=\s*[/>{{jsx_tag_name_start}}]) + scope: punctuation.definition.tag.begin.js + set: jsx-child-tag-begin + + jsx-child-tag-begin: + - meta_include_prototype: false + - meta_scope: meta.tag.js + - match: / + scope: punctuation.definition.tag.begin.js + set: + - jsx-expect-tag-end + - jsx-tag-name + - match: (?=\S) + set: + - jsx-body + - jsx-tag-attributes + - jsx-tag-name + + jsx-expect-tag-end: + - meta_content_scope: meta.tag.js + - match: '>{2,}' # ignore invalid punctuation + - match: '>' + scope: meta.tag.js punctuation.definition.tag.end.js + pop: 1 + - include: else-pop jsx-tag-attributes: - meta_content_scope: meta.tag.attributes.js - - match: '>{2,}' # ignore invalid punctuation - match: '>' scope: meta.tag.js punctuation.definition.tag.end.js set: jsx-body - - match: '/' scope: meta.tag.js punctuation.definition.tag.end.js set: jsx-expect-tag-end - - - include: jsx-interpolation - - match: '{{jsx_identifier}}' scope: entity.other.attribute-name.js - - match: '=' scope: punctuation.separator.key-value.js - push: jsx-attribute-value - - jsx-attribute-value: - - include: jsx-tag - - include: jsx-interpolation - - - match: "'" + - match: \" scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js - pop: 1 - - include: jsx-html-escapes - - match: '"' + push: jsx-double-quoted-string-body + - match: \' scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: string.quoted.double.js - - match: \" - scope: punctuation.definition.string.end.js - pop: 1 - - include: jsx-html-escapes + push: jsx-single-quoted-string-body + - include: jsx-interpolation - - include: else-pop + jsx-double-quoted-string-body: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js + pop: 1 + - include: jsx-html-escapes + + jsx-single-quoted-string-body: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js + pop: 1 + - include: jsx-html-escapes jsx-html-escapes: - - match: '(&)#?[[:alnum:]]+(;)' + - match: (&)#?[[:alnum:]]+(;) scope: constant.character.escape.js captures: 1: punctuation.definition.entity.js @@ -196,23 +202,6 @@ contexts: jsx-body: - meta_include_prototype: false - - match: '<(?=\s*[/>{{jsx_tag_name_start}}])' - scope: punctuation.definition.tag.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.tag.js - - - match: '/' - scope: punctuation.definition.tag.begin.js - set: - - jsx-expect-tag-end - - jsx-tag-name - - - match: (?=\S) - set: - - jsx-body - - jsx-tag-attributes - - jsx-tag-name - + - include: jsx-child-tag - include: jsx-html-escapes - include: jsx-interpolation diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 035704d713..395f11a35b 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -1185,7 +1185,7 @@ contexts: set: - detect-arrow - parenthesized-expression - - match: (?={{identifier_start}}) + - match: '' set: - detect-arrow - literal-variable @@ -2055,13 +2055,14 @@ contexts: parenthesized-expression: - match: \( scope: punctuation.section.group.begin.js - set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js - pop: 1 - - match: (?=\S) - push: expression + set: parenthesized-expression-body + + parenthesized-expression-body: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: 1 + - include: expressions function-call-arguments: - meta_content_scope: meta.function-call.js diff --git a/JavaScript/TSX.sublime-syntax b/JavaScript/TSX.sublime-syntax index f6a5631fd1..3941e5e75f 100644 --- a/JavaScript/TSX.sublime-syntax +++ b/JavaScript/TSX.sublime-syntax @@ -17,43 +17,49 @@ first_line_match: |- ) contexts: - branch-possible-arrow-function: - - meta_prepend: true - - include: jsx-tag - jsx-tag-hack: [] - - jsx-tag-name: - - meta_include_prototype: false - - match: '' + ts-old-type-assertion: + # old type assertions are replaced by JSX tags + - match: < + scope: punctuation.definition.tag.begin.js set: - - jsx-tag-name-meta - - tsx-tag-generic-arguments - - jsx-tag-name-end - - jsx-tag-name-component-possibly-native + - jsx-meta + - jsx-tag-begin - tsx-tag-generic-arguments: - - include: ts-generic-type-arguments - - include: else-pop + jsx-tag: [] # replaced by `ts-old-type-assertion` - jsx-tag-attributes-top: + jsx-tag-begin: - meta_include_prototype: false - meta_scope: meta.tag.js - - match: '/' + # note: type parameter modifiers indicate generic lambda + - match: (?=(?:in|out|const){{identifier_break}}) + fail: arrow-function + - match: / scope: punctuation.definition.tag.begin.js set: - - jsx-meta-unmatched-tag - - jsx-expect-tag-end + - jsx-expect-unmatched-tag-end - jsx-tag-name - - match: (?=\S) set: - jsx-tag-attributes - tsx-tag-check - jsx-tag-name + jsx-tag-name: + - meta_include_prototype: false + - match: '' + set: + - jsx-tag-name-meta + - tsx-tag-generic-arguments + - jsx-tag-name-end + - jsx-tag-name-component-possibly-native + + tsx-tag-generic-arguments: + - include: ts-generic-type-arguments + - include: else-pop + tsx-tag-check: - - match: 'extends{{jsx_identifier_break}}' + - match: extends{{jsx_identifier_break}} scope: entity.other.attribute-name.js set: - meta_include_prototype: false diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 844e88d513..279a98530e 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -106,81 +106,6 @@ contexts: - match: (?=\S) fail: ts-export-type-from - parenthesized-expression: - - match: \( - scope: punctuation.section.group.begin.js - set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js - pop: true - # Bail early when we see what looks like a type annotation. - - match: '\??:' - fail: arrow-function - - match: (?=\S) - push: expression - - branch-possible-arrow-function: - - meta_prepend: true - - match: (?=\() - set: - - detect-arrow - - ts-detect-parenthesized-arrow-return-type - - parenthesized-expression - - - match: \< - scope: punctuation.definition.assertion.begin.js - set: - - ts-old-type-assertion-check - - ts-old-type-assertion-end - - ts-type-expression-end - - ts-type-expression-end-no-line-terminator - - ts-type-expression-begin - - ts-detect-parenthesized-arrow-return-type: - - match: (?=:) - pop: 1 - branch_point: ts-arrow-function-return-type - branch: - - ts-detect-arrow-function-return-type - - immediately-pop - - include: else-pop - - ts-detect-arrow-function-return-type: - - meta_include_prototype: false - - match: '' - set: - - ts-detect-arrow-after-return-type - - ts-type-annotation - - ts-detect-arrow-after-return-type: - - match: (?==>) - fail: arrow-function - - match: (?=\S) - fail: ts-arrow-function-return-type - - async-arrow-function: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js - set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow-or-fail-async - - ts-type-annotation - - arrow-function-expect-parameters - - ts-type-parameter-list - - arrow-function-declaration: - - meta_include_prototype: false - - match: '' - set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow - - ts-type-annotation - - arrow-function-expect-parameters - - ts-type-parameter-list - ts-import-type: - match: (?=type{{identifier_break}}) pop: 1 @@ -728,6 +653,11 @@ contexts: - method-declaration-prefix - class-element-modifiers + decorator-expression-end: + - meta_prepend: true + - include: ts-function-type-arguments-or-less-than + - include: ts-non-null-assertion + left-expression-end: - meta_prepend: true - match: '{{function_call_after_lookahead}}' @@ -739,10 +669,95 @@ contexts: - include: ts-type-assertion - include: ts-function-type-arguments-or-less-than - decorator-expression-end: - - meta_prepend: true - - include: ts-function-type-arguments-or-less-than - - include: ts-non-null-assertion + async-arrow-function: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js + set: + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow-or-fail-async + - ts-type-annotation + - arrow-function-expect-parameters + - ts-type-parameter-list + + arrow-function-declaration: + - meta_include_prototype: false + - match: '' + set: + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow + - ts-type-annotation + - arrow-function-expect-parameters + - ts-type-parameter-list + + branch-possible-arrow-function: + - meta_include_prototype: false + - include: ts-old-type-assertion + - include: ts-parenthesized-expression + - match: '' + set: + - detect-arrow + - literal-variable + + ts-old-type-assertion: + - match: \< + scope: punctuation.definition.assertion.begin.js + set: + - ts-old-type-assertion-check + - ts-old-type-assertion-body + + ts-old-type-assertion-body: + - meta_scope: meta.assertion.js + - match: \> + scope: punctuation.definition.assertion.end.js + pop: 1 + - match: (?=\S) # Cover ts-type-parameter-list-head + push: + - ts-type-expression-end + - ts-type-expression-end-no-line-terminator + - ts-type-expression-begin + + ts-old-type-assertion-check: + - include: ts-parenthesized-expression + - include: else-pop + + ts-parenthesized-expression: + - match: \( + scope: punctuation.section.group.begin.js + set: + - ts-detect-arrow + - ts-parenthesized-expression-body + + ts-parenthesized-expression-body: + - meta_scope: meta.group.js + # Bail early when we see what looks like a type annotation. + - match: '\??:' + fail: arrow-function + - include: parenthesized-expression-body + + ts-detect-arrow: + - match: (?=:) + branch_point: ts-detect-arrow + branch: + - ts-detect-arrow-return-type + - immediately-pop-2 + - include: detect-arrow + + ts-detect-arrow-return-type: + - meta_include_prototype: false + - match: ':' + set: + - ts-detect-arrow-after-return-type + - ts-type-expression-end + - ts-type-expression-end-no-line-terminator + - ts-type-expression-begin + + ts-detect-arrow-after-return-type: + - match: (?==>) + fail: arrow-function + - match: (?=\S) + fail: ts-detect-arrow ts-function-type-arguments-or-less-than: - match: (?=<(?![<=])) @@ -780,25 +795,6 @@ contexts: scope: keyword.operator.comparison.js set: expression-begin - ts-old-type-assertion-end: - - meta_scope: meta.assertion.js - - match: \> - scope: punctuation.definition.assertion.end.js - pop: 1 - - match: (?=\S) # Cover ts-type-parameter-list-head - push: - - ts-type-expression-end - - ts-type-expression-end-no-line-terminator - - ts-type-expression-begin - - ts-old-type-assertion-check: - - match: (?=\() - set: - - detect-arrow - - ts-detect-parenthesized-arrow-return-type - - parenthesized-expression - - include: else-pop - ts-non-null-assertion: - match: '!(?!=)' scope: keyword.operator.type.js diff --git a/JavaScript/tests/syntax_test_jsx.jsx b/JavaScript/tests/syntax_test_jsx.jsx index 3de7a88e2f..c7443c5afc 100644 --- a/JavaScript/tests/syntax_test_jsx.jsx +++ b/JavaScript/tests/syntax_test_jsx.jsx @@ -146,6 +146,19 @@ // ^^^^^^ - meta.tag // ^^^^^^ meta.tag + foobarbazbarfoo; +// ^^^^^ meta.tag +// ^^^ - meta.tag +// ^^^^^ meta.tag +// ^^^ - meta.tag +// ^^^^^ meta.tag +// ^^^ - meta.tag +// ^^^^^^ meta.tag +// ^^^ - meta.tag +// ^^^^^^ meta.tag +// ^^^ - meta.tag +// ^^^^^^ meta.tag + // ^^^^^^^^^^^ meta.jsx // ^^^^^ - meta.jsx @@ -183,13 +196,27 @@ // ^ punctuation.separator.key-value 'test' -// ^^^^^^ string.quoted.single +// ^^^^^^ meta.string.js string.quoted.single + + baz 'test' +// ^^^^^^^^^^ meta.jsx meta.tag.attributes +// ^^^ entity.other.attribute-name +// ^^^^^^ meta.string.js string.quoted.single +// ^ punctuation.definition.string.begin +// ^ punctuation.definition.string.end baz='test' // ^^^^^^^^^^ meta.jsx meta.tag.attributes // ^^^ entity.other.attribute-name // ^ punctuation.separator.key-value -// ^^^^^^ string.quoted.single +// ^^^^^^ meta.string.js string.quoted.single +// ^ punctuation.definition.string.begin +// ^ punctuation.definition.string.end + + baz "test" +// ^^^^^^^^^^ meta.jsx meta.tag.attributes +// ^^^ entity.other.attribute-name +// ^^^^^^ meta.string.js string.quoted.double // ^ punctuation.definition.string.begin // ^ punctuation.definition.string.end @@ -197,12 +224,12 @@ // ^^^^^^^^^^ meta.jsx meta.tag.attributes // ^^^ entity.other.attribute-name // ^ punctuation.separator.key-value -// ^^^^^^ string.quoted.double +// ^^^^^^ meta.string.js string.quoted.double // ^ punctuation.definition.string.begin // ^ punctuation.definition.string.end baz="\n" -// ^^^^ string.quoted.double - constant.character.escape +// ^^^^ meta.string.js string.quoted.double - constant.character.escape baz="  " // ^^^^^^ constant.character.escape @@ -225,6 +252,11 @@ // ^^ meta.number.integer.decimal.js constant.numeric.value.js // ^ punctuation.section.interpolation.end + {attr}name={value} +// ^^^^^^ meta.interpolation +// ^^^^ entity.other.attribute-name +// ^ punctuation.separator.key-value +// ^^^^^^^ meta.interpolation {...attrs} // ^^^^^^^^^^ meta.interpolation diff --git a/JavaScript/tests/syntax_test_tsx.tsx b/JavaScript/tests/syntax_test_tsx.tsx index 60ca310b3e..eaea6df57a 100644 --- a/JavaScript/tests/syntax_test_tsx.tsx +++ b/JavaScript/tests/syntax_test_tsx.tsx @@ -232,6 +232,84 @@ if (a < b || c <= d) {} // ^ meta.tag.name entity.name.tag // ^ punctuation.terminator.statement + () => {}; // ; +// ^^^^^^^^^ meta.function meta.generic - meta.function meta.function +// ^^ meta.function.parameters - meta.function meta.function +// ^^^^^^ meta.function - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function.arrow +// ^^ meta.block +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end +// ^ punctuation.terminator.statement +// ^^^^^^^^ comment.line.double-slash +// ^^ punctuation.definition.comment + + () => {}; // ; +// ^^^^^^^^^^^^^^^^^ meta.function meta.generic - meta.function meta.function +// ^^ meta.function.parameters - meta.function meta.function +// ^^^^^^ meta.function - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^^^^^^^ storage.modifier.extends +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function.arrow +// ^^ meta.block +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end +// ^ punctuation.terminator.statement +// ^^^^^^^^ comment.line.double-slash +// ^^ punctuation.definition.comment + + () => {x}; // ; +// ^^^^^^^^^^^^^^^^^^^^^ meta.function meta.generic - meta.function meta.function +// ^^ meta.function.parameters - meta.function meta.function +// ^^^^^^^ meta.function - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^^^^^^^ storage.modifier.extends +// ^^^ meta.string string.quoted.double +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function.arrow +// ^^^ meta.block +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end +// ^ punctuation.terminator.statement +// ^^^^^^^^ comment.line.double-slash +// ^^ punctuation.definition.comment + + () => {x}; // ; +// ^^^^^^^^^^^^^^^^^^^^^ meta.function meta.generic - meta.function meta.function +// ^^ meta.function.parameters - meta.function meta.function +// ^^^^^^ meta.function - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^^^^^^^ storage.modifier.extends +// ^ keyword.operator.assignment.js +// ^^^ meta.string string.quoted.double +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function.arrow +// ^^^ meta.block +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end +// ^ punctuation.terminator.statement +// ^^^^^^^^ comment.line.double-slash +// ^^ punctuation.definition.comment + () => {};; // ^^^^^^^^^^^^^^^^^^^^^^ meta.jsx // ^^^^^^^^^ meta.tag diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 318712df38..6e28541b3c 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -1247,12 +1247,66 @@ let x: (this: any) => any; let x: < T > ( ... foo : any ) => any; // ^^^^^ meta.generic +// ^ punctuation.definition.generic.begin // ^ variable.parameter.generic +// ^ punctuation.definition.generic.end // ^^^^^^^^^^^^^^^^^ meta.group +// ^ punctuation.section.group.begin // ^^^ keyword.operator.spread // ^^^ variable.parameter // ^ punctuation.separator.type // ^^^ support.type.any +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function +// ^^^ support.type.any + +let x: < const T > ( ... foo : any ) => any; +// ^^^^^^^^^^^ meta.generic +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^ punctuation.definition.generic.end +// ^^^^^^^^^^^^^^^^^ meta.group +// ^ punctuation.section.group.begin +// ^^^ keyword.operator.spread +// ^^^ variable.parameter +// ^ punctuation.separator.type +// ^^^ support.type.any +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function +// ^^^ support.type.any + +let x: < in T > ( ... foo : any ) => any; +// ^^^^^^^^ meta.generic +// ^ punctuation.definition.generic.begin +// ^^ storage.modifier.variance +// ^ variable.parameter.generic +// ^ punctuation.definition.generic.end +// ^^^^^^^^^^^^^^^^^ meta.group +// ^ punctuation.section.group.begin +// ^^^ keyword.operator.spread +// ^^^ variable.parameter +// ^ punctuation.separator.type +// ^^^ support.type.any +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function +// ^^^ support.type.any + +let x: < out T > ( ... foo : any ) => any; +// ^^^^^^^^^ meta.generic +// ^ punctuation.definition.generic.begin +// ^^^ storage.modifier.variance +// ^ variable.parameter.generic +// ^ punctuation.definition.generic.end +// ^^^^^^^^^^^^^^^^^ meta.group +// ^ punctuation.section.group.begin +// ^^^ keyword.operator.spread +// ^^^ variable.parameter +// ^ punctuation.separator.type +// ^^^ support.type.any +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function +// ^^^ support.type.any let x: () => T U @@ -1360,6 +1414,16 @@ let x: T.U []; //<- meta.sequence - meta.type + foo != bar +// ^^^ variable.other.readwrite +// ^^ keyword.operator.comparison +// ^^^ variable.other.readwrite + + foo < bar +// ^^^ variable.other.readwrite +// ^ keyword.operator.comparison +// ^^^ variable.other.readwrite + foo < bar > (); // ^^^ variable.function // ^^^^^^^ meta.generic @@ -1368,12 +1432,6 @@ let x: T.U // ^ punctuation.definition.generic.end // ^^ meta.group - foo < bar -// ^^^ variable.other.readwrite -// ^ keyword.operator.comparison -// ^^^ variable.other.readwrite - ; - new Foo; // ^^^ keyword.operator.word.new // ^^^ variable.other.constant @@ -1420,8 +1478,71 @@ const f = >() => {}; // ^^ keyword.declaration.function.arrow // ^^ meta.block - a != b; -// ^^ keyword.operator.comparison +const f = () => foo; +// ^^^^^^^^^ meta.function meta.generic - meta.function meta.function +// ^^ meta.function.parameters - meta.function meta.function +// ^^^^^^^ meta.function - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^ keyword.declaration.function.arrow +// ^^^ meta.block variable.other.readwrite +// ^ punctuation.terminator.statement + +const f = (a: T,): T => foo; +// ^^^^^^^^^ meta.function meta.generic - meta.function meta.function +// ^^^^^^^ meta.function.parameters - meta.function meta.function +// ^ meta.function - meta.type - meta.function meta.function +// ^^^ meta.function meta.type - meta.function meta.function +// ^^^^^^ meta.function - meta.type - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ variable.parameter.function +// ^ punctuation.separator.type +// ^^ meta.type +// ^ support.class +// ^ punctuation.separator.parameter.function +// ^ punctuation.section.group.end +// ^ punctuation.separator.type +// ^ support.class +// ^^ keyword.declaration.function.arrow +// ^^^ meta.block variable.other.readwrite +// ^ punctuation.terminator.statement + +const f = (a: T,): X => foo; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.js meta.generic.js +// ^^^^^^^ meta.function.parameters - meta.function meta.function +// ^ meta.function - meta.type - meta.function meta.function +// ^^^ meta.function meta.type - meta.function meta.function +// ^^^^^^ meta.function - meta.type - meta.function meta.function +// ^ punctuation.definition.generic.begin +// ^^^^^ storage.modifier.const +// ^ variable.parameter.generic +// ^^^^^^^ storage.modifier.extends +// ^^^ support.class +// ^ punctuation.separator.comma +// ^ variable.parameter.generic +// ^^^^^^^ storage.modifier.extends +// ^^^ support.class +// ^ punctuation.definition.generic.end +// ^ punctuation.section.group.begin +// ^ meta.binding.name variable.parameter.function +// ^ punctuation.separator.type +// ^^ meta.type +// ^ support.class +// ^ punctuation.separator.parameter.function +// ^ punctuation.section.group.end +// ^ punctuation.separator.type +// ^ support.class +// ^^ keyword.declaration.function.arrow +// ^^^ meta.block variable.other.readwrite +// ^ punctuation.terminator.statement const x = { readonly: true,