11module td
22{
3+ /**
4+ * Represents a type that refers to another reflection like a class, interface or enum.
5+ *
6+ * ~~~
7+ * var value:MyClass;
8+ * ~~~
9+ */
310 export class ReferenceType extends Type
411 {
12+ /**
13+ * The name of the referenced type.
14+ *
15+ * If the symbol cannot be found cause it's not part of the documentation this
16+ * can be used to represent the type.
17+ */
518 name :string ;
619
20+ /**
21+ * The symbol id of the referenced type as returned from the TypeScript compiler.
22+ *
23+ * After the all reflections have been generated this is can be used to lookup the
24+ * relevant reflection with [[ProjectReflection.symbolMapping]].
25+ */
726 symbolID :number ;
827
28+ /**
29+ * The resolved reflection.
30+ *
31+ * The [[TypePlugin]] will try to set this property in the resolving phase.
32+ */
933 reflection :Reflection ;
1034
1135
36+
37+ /**
38+ * Create a new instance of ReferenceType.
39+ *
40+ * @param name The name of the referenced type.
41+ * @param symbolID The symbol id of the referenced type as returned from the TypeScript compiler.
42+ * @param reflection The resolved reflection if already known.
43+ */
1244 constructor ( name :string , symbolID :number , reflection ?:Reflection ) {
1345 super ( ) ;
1446 this . name = name ;
@@ -17,6 +49,21 @@ module td
1749 }
1850
1951
52+ /**
53+ * Return a raw object representation of this type.
54+ */
55+ toObject ( ) :any {
56+ var result :any = super . toObject ( ) ;
57+ result . type = 'reference' ;
58+ result . name = this . name ;
59+ result . symbolID = this . symbolID ;
60+ return result ;
61+ }
62+
63+
64+ /**
65+ * Return a string representation of this type.
66+ */
2067 toString ( ) {
2168 if ( this . reflection ) {
2269 return this . reflection . name + ( this . isArray ? '[]' : '' ) ;
0 commit comments