(function_signature
  name: (identifier) @name) @definition.function

(method_signature
  name: (property_identifier) @name) @definition.method

(abstract_method_signature
  name: (property_identifier) @name) @definition.method

(abstract_class_declaration
  name: (type_identifier) @name) @definition.class

(module
  name: (identifier) @name) @definition.module

(interface_declaration
  name: (type_identifier) @name) @definition.interface

(type_parameter
  name: (type_identifier) @name) @definition.type

(type_annotation
  (type_identifier) @name) @reference.type

(type_predicate
  (identifier) @name) @reference.variable

(new_expression
  constructor: (identifier) @name) @reference.class

(function_declaration
  name: (identifier) @name) @definition.function

(class_declaration
  name: (type_identifier) @name) @definition.class

(type_alias_declaration
  name: (type_identifier) @name) @definition.type

(enum_declaration
  name: (identifier) @name) @definition.enum

(lexical_declaration
  (variable_declarator
    name: (identifier) @name)) @definition.variable

(variable_declaration
  (variable_declarator
    name: (identifier) @name)) @definition.variable

(required_parameter
  (identifier) @name) @definition.parameter

(optional_parameter
  (identifier) @name) @definition.parameter

(call_expression
  function: (identifier) @name) @reference.call

(import_statement
  source: (string
    (string_fragment) @name)) @reference.module

(import_clause
  (identifier) @name) @reference.import

(namespace_import
  (identifier) @name) @reference.import

(import_specifier
  name: (identifier) @name) @reference.import

(import_specifier
  alias: (identifier) @name) @reference.import

[
  (binary_expression left: (identifier) @name)
  (binary_expression right: (identifier) @name)
  (unary_expression (identifier) @name)
  (return_statement (identifier) @name)
  (array (identifier) @name)
  (arguments (identifier) @name)
  (variable_declarator value: (identifier) @name)
  (assignment_expression right: (identifier) @name)
  (pair value: (identifier) @name)
  (await_expression (identifier) @name)
  (yield_expression (identifier) @name)
  (subscript_expression object: (identifier) @name)
  (shorthand_property_identifier) @name
  (ternary_expression condition: (identifier) @name)
  (ternary_expression consequence: (identifier) @name)
  (ternary_expression alternative: (identifier) @name)
  (template_substitution (identifier) @name)
  (non_null_expression (identifier) @name)
  (as_expression (identifier) @name)
] @reference.variable
