File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,20 @@ export function dominates(a: Type, b: Type): boolean {
140
140
return false ;
141
141
}
142
142
function addToUnion ( types : NonUnion [ ] , type : NonUnion ) : Type {
143
+ if ( type . kind === 'normal completion' ) {
144
+ const existingNormalCompletionIndex = types . findIndex ( t => t . kind === 'normal completion' ) ;
145
+ if ( existingNormalCompletionIndex !== - 1 ) {
146
+ // prettier-ignore
147
+ const joined = join ( types [ existingNormalCompletionIndex ] , type ) as Type & { kind : 'normal completion' } ;
148
+ if ( types . length === 1 ) {
149
+ return joined ;
150
+ }
151
+ const typesCopy = [ ...types ] ;
152
+ typesCopy . splice ( existingNormalCompletionIndex , 1 , joined ) ;
153
+ return { kind : 'union' , of : typesCopy } ;
154
+ }
155
+ }
156
+
143
157
if ( types . some ( t => dominates ( t , type ) ) ) {
144
158
return { kind : 'union' , of : types } ;
145
159
}
You can’t perform that action at this time.
0 commit comments