or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

async-generators.mdclass-system.mddecorators.mddestructuring.mdindex.mdmodule-interop.mdprivate-fields.mdtype-system.mdutilities.md

decorators.mddocs/

0

# Decorator Helpers

1

2

Support for decorator syntax including method decorators, class decorators, and property decorators.

3

4

## Capabilities

5

6

### Core Decorator Functions

7

8

#### _decorate

9

10

Applies decorators to class members and classes.

11

12

```javascript { .api }

13

/**

14

* Applies decorators to class members and classes

15

* @param {Array} decorators - Array of decorator functions

16

* @param {Function|Object} target - Target class or prototype

17

* @param {string|symbol} key - Property key (for member decorators)

18

* @param {Object} desc - Property descriptor

19

* @returns {any} Decorated result

20

*/

21

function _decorate(decorators, target, key, desc): any;

22

```

23

24

**Usage Example:**

25

26

```javascript

27

// For: @decorator class MyClass {}

28

_decorate([decorator], MyClass);

29

30

// For: @decorator method() {}

31

_decorate([decorator], MyClass.prototype, "method", descriptor);

32

```

33

34

#### _apply_decorated_descriptor

35

36

Applies decorated descriptors to object properties.

37

38

```javascript { .api }

39

/**

40

* Applies decorated descriptors to object properties

41

* @param {Object} target - Target object

42

* @param {string|symbol} property - Property key

43

* @param {Array} decorators - Array of decorators

44

* @param {Object} descriptor - Original property descriptor

45

* @param {Object} context - Decorator context

46

* @returns {Object} Updated descriptor

47

*/

48

function _apply_decorated_descriptor(target, property, decorators, descriptor, context): Object;

49

```

50

51

### Stage 3 Decorator Support

52

53

#### _apply_decs_2203_r

54

55

Applies Stage 3 decorators following the 2022-03 revision.

56

57

```javascript { .api }

58

/**

59

* Applies Stage 3 decorators following the 2022-03 revision

60

* @param {Function} targetClass - Target class

61

* @param {Array} memberDecs - Member decorators

62

* @param {Array} classDecs - Class decorators

63

* @param {Array} classDecsHaveThis - Class decorators with this context

64

* @param {number} instanceBrand - Instance brand value

65

* @returns {Object} Decorated class information

66

*/

67

function _apply_decs_2203_r(targetClass, memberDecs, classDecs, classDecsHaveThis, instanceBrand): Object;

68

```

69

70

### Initializer Helpers

71

72

#### _initializer_define_property

73

74

Defines properties using initializer functions.

75

76

```javascript { .api }

77

/**

78

* Defines properties using initializer functions

79

* @param {Object} target - Target object

80

* @param {string|symbol} key - Property key

81

* @param {Object} descriptor - Property descriptor

82

* @param {Object} context - Definition context

83

* @param {Function} initializer - Initializer function

84

*/

85

function _initializer_define_property(target, key, descriptor, context, initializer): void;

86

```

87

88

#### _initializer_warning_helper

89

90

Provides warnings for initializer usage.

91

92

```javascript { .api }

93

/**

94

* Provides warnings for initializer usage

95

* @param {Object} descriptor - Property descriptor

96

* @param {Object} context - Usage context

97

* @returns {Function} Warning function

98

*/

99

function _initializer_warning_helper(descriptor, context): Function;

100

```

101

102

### Descriptor Utilities

103

104

#### _class_apply_descriptor_get

105

106

Applies getter descriptors to class members.

107

108

```javascript { .api }

109

/**

110

* Applies getter descriptors to class members

111

* @param {Object} target - Target object

112

* @param {Object} descriptor - Getter descriptor

113

* @returns {any} Getter result

114

*/

115

function _class_apply_descriptor_get(target, descriptor): any;

116

```

117

118

#### _class_apply_descriptor_set

119

120

Applies setter descriptors to class members.

121

122

```javascript { .api }

123

/**

124

* Applies setter descriptors to class members

125

* @param {Object} target - Target object

126

* @param {Object} descriptor - Setter descriptor

127

* @param {any} value - Value to set

128

* @returns {any} Set value

129

*/

130

function _class_apply_descriptor_set(target, descriptor, value): any;

131

```

132

133

#### _class_apply_descriptor_update

134

135

Applies update descriptors to class members.

136

137

```javascript { .api }

138

/**

139

* Applies update descriptors to class members

140

* @param {Object} target - Target object

141

* @param {Object} descriptor - Update descriptor

142

* @param {Function} updateFn - Update function

143

* @returns {any} Updated value

144

*/

145

function _class_apply_descriptor_update(target, descriptor, updateFn): any;

146

```

147

148

#### _class_apply_descriptor_destructure

149

150

Applies destructure descriptors to class members.

151

152

```javascript { .api }

153

/**

154

* Applies destructure descriptors to class members

155

* @param {Object} target - Target object

156

* @param {Object} descriptor - Destructure descriptor

157

* @returns {any} Destructured value

158

*/

159

function _class_apply_descriptor_destructure(target, descriptor): any;

160

```

161

162

#### _class_extract_field_descriptor

163

164

Extracts field descriptors from class members.

165

166

```javascript { .api }

167

/**

168

* Extracts field descriptors from class members

169

* @param {Object} target - Target object

170

* @param {string|symbol} key - Property key

171

* @param {boolean} isStatic - Whether field is static

172

* @returns {Object} Field descriptor

173

*/

174

function _class_extract_field_descriptor(target, key, isStatic): Object;

175

```

176

177

### TypeScript Decorator Support

178

179

#### _ts_decorate

180

181

TypeScript-specific decorator implementation (re-exported from tslib).

182

183

```javascript { .api }

184

/**

185

* TypeScript-specific decorator implementation (re-exported from tslib.__decorate)

186

* @param {Array} decorators - Array of decorators

187

* @param {Function|Object} target - Target class or prototype

188

* @param {string|symbol} key - Property key

189

* @param {Object} descriptor - Property descriptor

190

* @returns {any} Decorated result

191

*/

192

function _ts_decorate(decorators, target, key, descriptor): any;

193

```

194

195

#### _ts_metadata

196

197

Handles TypeScript metadata for decorators (re-exported from tslib).

198

199

```javascript { .api }

200

/**

201

* Handles TypeScript metadata for decorators (re-exported from tslib.__metadata)

202

* @param {string} metadataKey - Metadata key

203

* @param {any} metadataValue - Metadata value

204

* @returns {Function} Metadata decorator

205

*/

206

function _ts_metadata(metadataKey, metadataValue): Function;

207

```

208

209

#### _ts_param

210

211

TypeScript parameter decorator helper (re-exported from tslib).

212

213

```javascript { .api }

214

/**

215

* TypeScript parameter decorator helper (re-exported from tslib.__param)

216

* @param {number} paramIndex - Parameter index

217

* @param {Function} decorator - Parameter decorator

218

* @returns {Function} Parameter decorator function

219

*/

220

function _ts_param(paramIndex, decorator): Function;

221

```