Skip to content

Commit 0eef403

Browse files
Add test case for decorator support
1 parent a0faec0 commit 0eef403

File tree

2 files changed

+364
-0
lines changed

2 files changed

+364
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/// <reference path="../lib.core.d.ts" />
2+
3+
4+
/**
5+
* A decorated class.
6+
*/
7+
@decoratorWithOptions({
8+
name: 'Name of class'
9+
})
10+
class DecoratedClass
11+
{
12+
/**
13+
* A decorated method.
14+
*/
15+
@decoratorAtom
16+
@decoratorWithParam(false)
17+
decoratedMethod() { }
18+
}
19+
20+
21+
/**
22+
* A decorator with no options.
23+
*/
24+
function decoratorAtom(target, key, descriptor) {
25+
descriptor.writable = false;
26+
}
27+
28+
29+
/**
30+
* A decorator with a parameter.
31+
*
32+
* @param value The parameter of this decorator.
33+
*/
34+
function decoratorWithParam(value:boolean) {
35+
return function (target, key, descriptor) {
36+
descriptor.enumerable = value;
37+
}
38+
}
39+
40+
41+
/**
42+
* A decorator consuming an options object.
43+
*
44+
* @param options The options object of this decorator.
45+
* @param options.name A property on the options object of this decorator.
46+
*/
47+
function decoratorWithOptions(options:{name:string}) {
48+
return function (target, key, descriptor) {
49+
descriptor.options = options;
50+
}
51+
}
Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
{
2+
"id": 0,
3+
"name": "typedoc",
4+
"kind": 0,
5+
"flags": {},
6+
"children": [
7+
{
8+
"id": 1,
9+
"name": "\"decorators\"",
10+
"kind": 1,
11+
"kindString": "External module",
12+
"flags": {
13+
"isExported": true
14+
},
15+
"originalName": "%BASE%/decorators/decorators.ts",
16+
"children": [
17+
{
18+
"id": 2,
19+
"name": "DecoratedClass",
20+
"kind": 128,
21+
"kindString": "Class",
22+
"flags": {},
23+
"comment": {
24+
"shortText": "A decorated class."
25+
},
26+
"decorators": [
27+
{
28+
"name": "decoratorWithOptions",
29+
"type": {
30+
"type": "reference",
31+
"name": "decoratorWithOptions",
32+
"id": 13
33+
},
34+
"arguments": {
35+
"options": "{\n name: 'Name of class'\n}"
36+
}
37+
}
38+
],
39+
"children": [
40+
{
41+
"id": 3,
42+
"name": "decoratedMethod",
43+
"kind": 2048,
44+
"kindString": "Method",
45+
"flags": {},
46+
"decorators": [
47+
{
48+
"name": "decoratorAtom",
49+
"type": {
50+
"type": "reference",
51+
"name": "decoratorAtom",
52+
"id": 5
53+
}
54+
},
55+
{
56+
"name": "decoratorWithParam",
57+
"type": {
58+
"type": "reference",
59+
"name": "decoratorWithParam",
60+
"id": 10
61+
},
62+
"arguments": {
63+
"value": "false"
64+
}
65+
}
66+
],
67+
"signatures": [
68+
{
69+
"id": 4,
70+
"name": "decoratedMethod",
71+
"kind": 4096,
72+
"kindString": "Call signature",
73+
"flags": {},
74+
"comment": {
75+
"shortText": "A decorated method."
76+
},
77+
"type": {
78+
"type": "instrinct",
79+
"name": "void"
80+
}
81+
}
82+
]
83+
}
84+
],
85+
"groups": [
86+
{
87+
"title": "Methods",
88+
"kind": 2048,
89+
"children": [
90+
3
91+
]
92+
}
93+
]
94+
},
95+
{
96+
"id": 5,
97+
"name": "decoratorAtom",
98+
"kind": 64,
99+
"kindString": "Function",
100+
"flags": {},
101+
"decorates": [
102+
{
103+
"type": "reference",
104+
"name": "decoratedMethod",
105+
"id": 3
106+
}
107+
],
108+
"signatures": [
109+
{
110+
"id": 6,
111+
"name": "decoratorAtom",
112+
"kind": 4096,
113+
"kindString": "Call signature",
114+
"flags": {},
115+
"comment": {
116+
"shortText": "A decorator with no options."
117+
},
118+
"parameters": [
119+
{
120+
"id": 7,
121+
"name": "target",
122+
"kind": 32768,
123+
"kindString": "Parameter",
124+
"flags": {},
125+
"type": {
126+
"type": "instrinct",
127+
"name": "any"
128+
}
129+
},
130+
{
131+
"id": 8,
132+
"name": "key",
133+
"kind": 32768,
134+
"kindString": "Parameter",
135+
"flags": {},
136+
"type": {
137+
"type": "instrinct",
138+
"name": "any"
139+
}
140+
},
141+
{
142+
"id": 9,
143+
"name": "descriptor",
144+
"kind": 32768,
145+
"kindString": "Parameter",
146+
"flags": {},
147+
"type": {
148+
"type": "instrinct",
149+
"name": "any"
150+
}
151+
}
152+
],
153+
"type": {
154+
"type": "instrinct",
155+
"name": "void"
156+
}
157+
}
158+
]
159+
},
160+
{
161+
"id": 13,
162+
"name": "decoratorWithOptions",
163+
"kind": 64,
164+
"kindString": "Function",
165+
"flags": {},
166+
"decorates": [
167+
{
168+
"type": "reference",
169+
"name": "DecoratedClass",
170+
"id": 2
171+
}
172+
],
173+
"signatures": [
174+
{
175+
"id": 14,
176+
"name": "decoratorWithOptions",
177+
"kind": 4096,
178+
"kindString": "Call signature",
179+
"flags": {},
180+
"comment": {
181+
"shortText": "A decorator consuming an options object."
182+
},
183+
"parameters": [
184+
{
185+
"id": 15,
186+
"name": "options",
187+
"kind": 32768,
188+
"kindString": "Parameter",
189+
"flags": {},
190+
"comment": {
191+
"text": "The options object of this decorator."
192+
},
193+
"type": {
194+
"type": "reflection",
195+
"declaration": {
196+
"id": 16,
197+
"name": "__type",
198+
"kind": 65536,
199+
"kindString": "Type literal",
200+
"flags": {},
201+
"children": [
202+
{
203+
"id": 17,
204+
"name": "name",
205+
"kind": 32,
206+
"kindString": "Variable",
207+
"flags": {},
208+
"comment": {
209+
"text": "A property on the options object of this decorator.\n"
210+
},
211+
"type": {
212+
"type": "instrinct",
213+
"name": "string"
214+
}
215+
}
216+
],
217+
"groups": [
218+
{
219+
"title": "Variables",
220+
"kind": 32,
221+
"children": [
222+
17
223+
]
224+
}
225+
]
226+
}
227+
}
228+
}
229+
],
230+
"type": {
231+
"type": "reference",
232+
"name": "__function"
233+
}
234+
}
235+
]
236+
},
237+
{
238+
"id": 10,
239+
"name": "decoratorWithParam",
240+
"kind": 64,
241+
"kindString": "Function",
242+
"flags": {},
243+
"decorates": [
244+
{
245+
"type": "reference",
246+
"name": "decoratedMethod",
247+
"id": 3
248+
}
249+
],
250+
"signatures": [
251+
{
252+
"id": 11,
253+
"name": "decoratorWithParam",
254+
"kind": 4096,
255+
"kindString": "Call signature",
256+
"flags": {},
257+
"comment": {
258+
"shortText": "A decorator with a parameter."
259+
},
260+
"parameters": [
261+
{
262+
"id": 12,
263+
"name": "value",
264+
"kind": 32768,
265+
"kindString": "Parameter",
266+
"flags": {},
267+
"comment": {
268+
"text": "The parameter of this decorator.\n"
269+
},
270+
"type": {
271+
"type": "instrinct",
272+
"name": "boolean"
273+
}
274+
}
275+
],
276+
"type": {
277+
"type": "reference",
278+
"name": "__function"
279+
}
280+
}
281+
]
282+
}
283+
],
284+
"groups": [
285+
{
286+
"title": "Classes",
287+
"kind": 128,
288+
"children": [
289+
2
290+
]
291+
},
292+
{
293+
"title": "Functions",
294+
"kind": 64,
295+
"children": [
296+
5,
297+
13,
298+
10
299+
]
300+
}
301+
]
302+
}
303+
],
304+
"groups": [
305+
{
306+
"title": "External modules",
307+
"kind": 1,
308+
"children": [
309+
1
310+
]
311+
}
312+
]
313+
}

0 commit comments

Comments
 (0)