0
# Utility Helpers
1
2
General-purpose utility functions for error handling, property operations, resource management, and other common runtime needs.
3
4
## Capabilities
5
6
### Error Handling
7
8
#### _throw
9
10
Throws an error (used for expression contexts).
11
12
```javascript { .api }
13
/**
14
* Throws an error (used for expression contexts)
15
* @param {Error} error - Error to throw
16
* @throws {Error} The provided error
17
*/
18
function _throw(error): never;
19
```
20
21
**Usage Example:**
22
23
```javascript
24
// In expressions where throw is needed
25
const value = condition ? validValue : _throw(new Error("Invalid condition"));
26
```
27
28
#### _read_only_error
29
30
Throws a read-only property error.
31
32
```javascript { .api }
33
/**
34
* Throws a read-only property error
35
* @param {string} name - Property name
36
* @throws {TypeError} Read-only property error
37
*/
38
function _read_only_error(name): never;
39
```
40
41
#### _write_only_error
42
43
Throws a write-only property error.
44
45
```javascript { .api }
46
/**
47
* Throws a write-only property error
48
* @param {string} name - Property name
49
* @throws {TypeError} Write-only property error
50
*/
51
function _write_only_error(name): never;
52
```
53
54
### Resource Management
55
56
#### _dispose
57
58
Handles resource disposal for using declarations.
59
60
```javascript { .api }
61
/**
62
* Handles resource disposal for using declarations
63
* @param {Array} stack - Disposal stack
64
* @param {Error} error - Current error
65
* @param {boolean} hasError - Whether an error occurred
66
* @returns {Promise|void} Disposal result
67
*/
68
function _dispose(stack, error, hasError): Promise<void> | void;
69
```
70
71
#### _using
72
73
Creates using declaration contexts.
74
75
```javascript { .api }
76
/**
77
* Creates using declaration contexts
78
* @param {any} disposable - Disposable resource
79
* @param {Array} stack - Disposal stack
80
* @param {boolean} isAsync - Whether disposal is async
81
* @returns {any} The disposable resource
82
*/
83
function _using(disposable, stack, isAsync): any;
84
```
85
86
#### _using_ctx
87
88
Creates using declaration context objects.
89
90
```javascript { .api }
91
/**
92
* Creates using declaration context objects
93
* @returns {Object} Using context with disposal stack
94
*/
95
function _using_ctx(): Object;
96
```
97
98
#### _ts_add_disposable_resource
99
100
TypeScript-specific disposable resource handling (re-exported from tslib).
101
102
```javascript { .api }
103
/**
104
* TypeScript-specific disposable resource handling (re-exported from tslib.__addDisposableResource)
105
* @param {Object} env - Environment object
106
* @param {any} value - Disposable value
107
* @param {boolean} async - Whether disposal is async
108
* @returns {any} The disposable value
109
*/
110
function _ts_add_disposable_resource(env, value, async): any;
111
```
112
113
#### _ts_dispose_resources
114
115
TypeScript-specific resource disposal (re-exported from tslib).
116
117
```javascript { .api }
118
/**
119
* TypeScript-specific resource disposal (re-exported from tslib.__disposeResources)
120
* @param {Object} env - Environment object with disposal stack
121
* @returns {Promise|void} Disposal result
122
*/
123
function _ts_dispose_resources(env): Promise<void> | void;
124
```
125
126
### JSX Helpers
127
128
#### _jsx
129
130
Creates JSX elements (React elements).
131
132
```javascript { .api }
133
/**
134
* Creates JSX elements (React elements)
135
* @param {string|Function} type - Element type
136
* @param {Object} props - Element properties
137
* @param {string|number} key - Element key
138
* @param {...any} children - Child elements
139
* @returns {Object} React element object
140
*/
141
function _jsx(type, props, key, children): Object;
142
```
143
144
**Usage Example:**
145
146
```javascript
147
// For: <div className="container">Hello</div>
148
const element = _jsx("div", { className: "container" }, undefined, "Hello");
149
```