Improve TS/TSX/JS syntax highlighting for parameters, types, and punctuation (#43437)

This pull request enhances syntax highlighting for JavaScript,
TypeScript, TSX, and JSDoc by adding more precise rules for parameters,
types, and punctuation.

- Added queries for highlighting parameters (`@variable.parameter`)
- Expanded highlighting for type identifiers, type aliases, interfaces,
classes
- Extended/implemented types to improve distinction between different
type constructs (`@type`, `@type.class`)
- Added highlighting for punctuation in type parameters, unions,
intersections, annotations, index signatures, optional fields, and
predicates (`@punctuation.special`, `@punctuation.bracket`)
- Added highlighting for identifiers in JSDoc comments
(`@variable.jsdoc`)

Release Notes:

- Refined syntax highlighting in JavaScript and TypeScript for better
visual distinction of
  types, parameters, and JSDoc elements
This commit is contained in:
Clay Tercek authored and GitHub committed 2025-12-08 12:00:38 +01:00
1 parent f16913400a
commit 9364d39487
4 files changed
+221 -6

No files matched your search

+37 -2
View File
@@ -47,10 +47,45 @@
left: (identifier) @function
right: [(function_expression) (arrow_function)])
; Parameters
(required_parameter
(identifier) @variable.parameter)
(required_parameter
(_
([
(identifier)
(shorthand_property_identifier_pattern)
]) @variable.parameter))
(optional_parameter
(identifier) @variable.parameter)
(optional_parameter
(_
([
(identifier)
(shorthand_property_identifier_pattern)
]) @variable.parameter))
(catch_clause
parameter: (identifier) @variable.parameter)
(index_signature
name: (identifier) @variable.parameter)
(arrow_function
parameter: (identifier) @variable.parameter)
; Special identifiers
;
(class_declaration
(type_identifier) @type.class)
(extends_clause
value: (identifier) @type.class)
((identifier) @type
(#match? @type "^[A-Z]"))
(type_identifier) @type
(predefined_type) @type.builtin