Typescript
TypeScript-specific configuration for syntax chunking.
logger
module-attribute
logger = getLogger(__name__)
TypeScriptConfig
dataclass
Bases: LanguageConfig
TypeScript-specific syntax chunking configuration.
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
module
class-attribute
module: list[str] = ['program']
namespace
class-attribute
namespace: list[str] = [
"export_statement",
"namespace_declaration",
]
class_
class-attribute
class_: list[str] = ['class_declaration', 'class']
interface
class-attribute
interface: list[str] = ['interface_declaration']
protocol
class-attribute
protocol: list[str] = []
struct
class-attribute
struct: list[str] = []
enum
class-attribute
enum: list[str] = ['enum_declaration']
type_alias
class-attribute
type_alias: list[str] = ['type_alias_declaration']
function
class-attribute
function: list[str] = [*function, 'function_signature']
method
class-attribute
method: list[str] = [*method, 'method_signature']
property_def
class-attribute
property_def: list[str] = [
*property_def,
"public_field_definition",
]
test_case
class-attribute
test_case: list[str] = test_case
test_suite
class-attribute
test_suite: list[str] = test_suite
variable
class-attribute
variable: list[str] = variable
constant
class-attribute
constant: list[str] = constant
class_field
class-attribute
class_field: list[str] = [
*class_field,
"public_field_definition",
]
import_
class-attribute
import_: list[str] = [*import_, 'import_alias']
decorator
class-attribute
decorator: list[str] = decorator
comment
class-attribute
comment: list[str] = comment
docstring
class-attribute
docstring: list[str] = docstring
file_extensions
class-attribute
file_extensions: list[str] = ['.ts', '.tsx']
tree_sitter_name
class-attribute
tree_sitter_name: str = 'typescript'
TypeScriptSyntaxHandler
Bases: JavaScriptSyntaxHandler
TypeScript-specific syntax handling logic.
Inherits from JavaScript handler to reuse common logic.
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
__init__
__init__() -> None
Initialize with TypeScript configuration.
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
68 69 70 71 |
|
get_entity_type
get_entity_type(
node: Node, parent: Node | None, content_bytes: bytes
) -> EntityType
Determine the EntityType for a TypeScript node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The tree-sitter node |
required |
parent
|
Node | None
|
The parent node (if any) |
required |
content_bytes
|
bytes
|
Source code content as bytes |
required |
Returns:
Type | Description |
---|---|
EntityType
|
The entity type |
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
extract_name
extract_name(node: Node, content_bytes: bytes) -> str
Extract the name identifier from a definition node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The tree-sitter node |
required |
content_bytes
|
bytes
|
Source code content as bytes |
required |
Returns:
Type | Description |
---|---|
str
|
The extracted name |
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
get_body_node
get_body_node(node: Node) -> Node | None
Get the node representing the 'body' of a definition.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The tree-sitter node |
required |
Returns:
Type | Description |
---|---|
Node | None
|
The body node if available, None otherwise |
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
get_children_to_process
get_children_to_process(
node: Node, body_node: Node | None
) -> list[Node]
Get the list of child nodes that should be recursively processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The tree-sitter node |
required |
body_node
|
Node | None
|
The body node if available |
required |
Returns:
Type | Description |
---|---|
list[Node]
|
List of child nodes to process |
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
extract_imports
extract_imports(
node: Node, content_bytes: bytes
) -> list[str]
Extract imported module names from a TypeScript import statement.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The tree-sitter node representing an import statement |
required |
content_bytes
|
bytes
|
Source code content as bytes |
required |
Returns:
Type | Description |
---|---|
list[str]
|
List of imported module names as strings |
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
get_enclosing_node_of_type
get_enclosing_node_of_type(
node: Node, target_type: EntityType
) -> Node | None
Find the first ancestor node matching the target TypeScript entity type.
Handles INTERFACE specifically and falls back to the JavaScript handler for other types (CLASS, FUNCTION, METHOD, MODULE).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The starting node. |
required |
target_type
|
EntityType
|
The EntityType to search for in ancestors. |
required |
Returns:
Type | Description |
---|---|
Node | None
|
The ancestor node if found, otherwise None. |
Source code in src/codemap/processor/tree_sitter/languages/typescript.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|