File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,19 @@ 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
+ const joined = join ( types [ existingNormalCompletionIndex ] , type ) as Type & { kind : 'normal completion' } ;
147
+ if ( types . length === 1 ) {
148
+ return joined ;
149
+ }
150
+ const typesCopy = [ ...types ] ;
151
+ typesCopy . splice ( existingNormalCompletionIndex , 1 , joined ) ;
152
+ return { kind : 'union' , of : typesCopy } ;
153
+ }
154
+ }
155
+
143
156
if ( types . some ( t => dominates ( t , type ) ) ) {
144
157
return { kind : 'union' , of : types } ;
145
158
}
You can’t perform that action at this time.
0 commit comments