File tree Expand file tree Collapse file tree 6 files changed +161
-38
lines changed Expand file tree Collapse file tree 6 files changed +161
-38
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ export function flattenTypes(
1111 nodeToProcess : typeof UnionNode | typeof IntersectionNode ,
1212) : TypeNode [ ] {
1313 let flatTypes : TypeNode [ ] = [ ] ;
14- nodes . forEach ( ( x ) => {
15- if ( x instanceof nodeToProcess ) {
16- flatTypes = flatTypes . concat ( flattenTypes ( x . types , nodeToProcess ) ) ;
14+ nodes . forEach ( ( node ) => {
15+ if ( node instanceof nodeToProcess && ! node . name ) {
16+ flatTypes = flatTypes . concat ( flattenTypes ( node . types , nodeToProcess ) ) ;
1717 } else {
18- flatTypes . push ( x ) ;
18+ flatTypes . push ( node ) ;
1919 }
2020 } ) ;
2121
Original file line number Diff line number Diff line change @@ -94,8 +94,14 @@ export function resolveType(
9494 typeName = undefined ;
9595 }
9696
97- for ( const memberType of type . types ) {
98- memberTypes . push ( resolveType ( memberType , memberType . getSymbol ( ) ?. name || '' , context ) ) ;
97+ // @ts -expect-error - Internal API
98+ if ( type . origin ) {
99+ // @ts -expect-error - Internal API
100+ return resolveType ( type . origin , name , context ) ;
101+ } else {
102+ for ( const memberType of type . types ) {
103+ memberTypes . push ( resolveType ( memberType , memberType . getSymbol ( ) ?. name || '' , context ) ) ;
104+ }
99105 }
100106
101107 return memberTypes . length === 1 ? memberTypes [ 0 ] : new UnionNode ( typeName , memberTypes ) ;
Original file line number Diff line number Diff line change 162162 "types" : [
163163 {
164164 "kind" : " reference" ,
165- "name" : " RefCallback"
166- },
167- {
168- "kind" : " reference" ,
169- "name" : " RefObject<any>"
170- },
171- {
172- "kind" : " intrinsic" ,
173- "name" : " null"
165+ "name" : " Ref<any>"
174166 },
175167 {
176168 "kind" : " intrinsic" ,
191183 "types" : [
192184 {
193185 "kind" : " reference" ,
194- "name" : " RefCallback"
195- },
196- {
197- "kind" : " reference" ,
198- "name" : " RefObject<any>"
199- },
200- {
201- "kind" : " intrinsic" ,
202- "name" : " null"
186+ "name" : " Ref<any>"
203187 },
204188 {
205189 "kind" : " intrinsic" ,
Original file line number Diff line number Diff line change @@ -2,16 +2,19 @@ export function test1(parameters: Params) {}
22export function test2 (
33 inlineStringUnion : 'foo' | 'bar' | 'baz' ,
44 inlineNumberUnion : 1 | 2 | 3 ,
5- referencedStringUnion : StringUniuon ,
5+ referencedStringUnion : StringUnion ,
66 referencedNumberUnion : NumberUnion ,
7+ unionOfUnions : StringUnion | NumberUnion ,
78) { }
89
910export interface Params {
1011 inlineStringUnion : 'foo' | 'bar' | 'baz' ;
1112 inlineNumberUnion : 1 | 2 | 3 ;
12- referencedStringUnion : StringUniuon ;
13+ referencedStringUnion : StringUnion ;
1314 referencedNumberUnion : NumberUnion ;
15+ callback : ( ref : StringUnion | undefined ) => void ;
16+ unionOfUnions : StringUnion | NumberUnion ;
1417}
1518
16- type StringUniuon = 'foo' | 'bar' | 'baz' ;
19+ type StringUnion = 'foo' | 'bar' | 'baz' ;
1720type NumberUnion = 1 | 2 | 3 ;
Original file line number Diff line number Diff line change 6262 "name" : " referencedStringUnion" ,
6363 "type" : {
6464 "kind" : " union" ,
65- "name" : " StringUniuon " ,
65+ "name" : " StringUnion " ,
6666 "types" : [
6767 {
6868 "kind" : " literal" ,
101101 ]
102102 },
103103 "optional" : false
104+ },
105+ {
106+ "name" : " callback" ,
107+ "type" : {
108+ "kind" : " function" ,
109+ "callSignatures" : [
110+ {
111+ "parameters" : [
112+ {
113+ "nodeType" : " parameter" ,
114+ "name" : " ref" ,
115+ "type" : {
116+ "kind" : " union" ,
117+ "types" : [
118+ {
119+ "kind" : " union" ,
120+ "name" : " StringUnion" ,
121+ "types" : [
122+ {
123+ "kind" : " literal" ,
124+ "value" : " \" foo\" "
125+ },
126+ {
127+ "kind" : " literal" ,
128+ "value" : " \" bar\" "
129+ },
130+ {
131+ "kind" : " literal" ,
132+ "value" : " \" baz\" "
133+ }
134+ ]
135+ },
136+ {
137+ "kind" : " intrinsic" ,
138+ "name" : " undefined"
139+ }
140+ ]
141+ }
142+ }
143+ ],
144+ "returnValueType" : {
145+ "kind" : " intrinsic" ,
146+ "name" : " void"
147+ }
148+ }
149+ ]
150+ },
151+ "optional" : false
152+ },
153+ {
154+ "name" : " unionOfUnions" ,
155+ "type" : {
156+ "kind" : " union" ,
157+ "types" : [
158+ {
159+ "kind" : " union" ,
160+ "name" : " StringUnion" ,
161+ "types" : [
162+ {
163+ "kind" : " literal" ,
164+ "value" : " \" foo\" "
165+ },
166+ {
167+ "kind" : " literal" ,
168+ "value" : " \" bar\" "
169+ },
170+ {
171+ "kind" : " literal" ,
172+ "value" : " \" baz\" "
173+ }
174+ ]
175+ },
176+ {
177+ "kind" : " union" ,
178+ "name" : " NumberUnion" ,
179+ "types" : [
180+ {
181+ "kind" : " literal" ,
182+ "value" : 1
183+ },
184+ {
185+ "kind" : " literal" ,
186+ "value" : 2
187+ },
188+ {
189+ "kind" : " literal" ,
190+ "value" : 3
191+ }
192+ ]
193+ }
194+ ]
195+ },
196+ "optional" : false
104197 }
105198 ]
106199 }
169262 "name" : " referencedStringUnion" ,
170263 "type" : {
171264 "kind" : " union" ,
172- "name" : " StringUniuon " ,
265+ "name" : " StringUnion " ,
173266 "types" : [
174267 {
175268 "kind" : " literal" ,
207300 }
208301 ]
209302 }
303+ },
304+ {
305+ "nodeType" : " parameter" ,
306+ "name" : " unionOfUnions" ,
307+ "type" : {
308+ "kind" : " union" ,
309+ "types" : [
310+ {
311+ "kind" : " union" ,
312+ "name" : " StringUnion" ,
313+ "types" : [
314+ {
315+ "kind" : " literal" ,
316+ "value" : " \" foo\" "
317+ },
318+ {
319+ "kind" : " literal" ,
320+ "value" : " \" bar\" "
321+ },
322+ {
323+ "kind" : " literal" ,
324+ "value" : " \" baz\" "
325+ }
326+ ]
327+ },
328+ {
329+ "kind" : " union" ,
330+ "name" : " NumberUnion" ,
331+ "types" : [
332+ {
333+ "kind" : " literal" ,
334+ "value" : 1
335+ },
336+ {
337+ "kind" : " literal" ,
338+ "value" : 2
339+ },
340+ {
341+ "kind" : " literal" ,
342+ "value" : 3
343+ }
344+ ]
345+ }
346+ ]
347+ }
210348 }
211349 ],
212350 "returnValueType" : {
Original file line number Diff line number Diff line change 7272 "types" : [
7373 {
7474 "kind" : " reference" ,
75- "name" : " RefCallback"
76- },
77- {
78- "kind" : " reference" ,
79- "name" : " RefObject<HTMLInputElement | null>"
80- },
81- {
82- "kind" : " intrinsic" ,
83- "name" : " null"
75+ "name" : " Ref<HTMLInputElement>"
8476 },
8577 {
8678 "kind" : " intrinsic" ,
You can’t perform that action at this time.
0 commit comments