;; TypeScript/TSX 标签查询
;; 定义使用 @name.definition.* 前缀
;; 引用使用 @name.reference.* 前缀

;; ==================== 定义 ====================

;; 函数定义
(function_declaration
  name: (identifier) @name.definition.function) @definition.function

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

;; 箭头函数赋值
(lexical_declaration
  (variable_declarator
    name: (identifier) @name.definition.function
    value: (arrow_function))) @definition.function

(variable_declaration
  (variable_declarator
    name: (identifier) @name.definition.function
    value: (arrow_function))) @definition.function

;; 方法定义
(method_definition
  name: (property_identifier) @name.definition.method) @definition.method

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

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

;; 类定义
(class_declaration
  name: (type_identifier) @name.definition.class) @definition.class

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

;; 接口定义
(interface_declaration
  name: (type_identifier) @name.definition.interface) @definition.interface

;; 类型别名
(type_alias_declaration
  name: (type_identifier) @name.definition.type) @definition.type

;; 枚举
(enum_declaration
  name: (identifier) @name.definition.enum) @definition.enum

;; 模块/命名空间
(module
  name: (identifier) @name.definition.module) @definition.module

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

;; ==================== 引用 ====================

;; 类型注解引用
(type_annotation
  (type_identifier) @name.reference.type) @reference.type

;; 类型参数中的引用
(type_arguments
  (type_identifier) @name.reference.type) @reference.type

;; extends/implements
(class_heritage
  (extends_clause
    value: (identifier) @name.reference.class)) @reference.class

(class_heritage
  (implements_clause
    (type_identifier) @name.reference.interface)) @reference.interface

;; new 表达式
(new_expression
  constructor: (identifier) @name.reference.class) @reference.class

;; 函数调用
(call_expression
  function: (identifier) @name.reference.call) @reference.call

(call_expression
  function: (member_expression
    property: (property_identifier) @name.reference.call)) @reference.call
