@@ -3055,7 +3055,7 @@ namespace ts {
3055
3055
3056
3056
function getRestType(source: Type, properties: PropertyName[], symbol: Symbol): Type {
3057
3057
if (source.flags & TypeFlags.Union) {
3058
- const types = filter(( <UnionType>source).types, t => !(t.flags & TypeFlags.Nullable) );
3058
+ const types = filterNulableTypes( <UnionType>source);
3059
3059
if (types.length) {
3060
3060
return getUnionType(map(types, t => getRestType(t, properties, symbol)));
3061
3061
}
@@ -6103,6 +6103,10 @@ namespace ts {
6103
6103
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
6104
6104
}
6105
6105
6106
+ function filterNulableTypes(union: UnionType): Type[] {
6107
+ return filter(union.types, t => !(t.flags & TypeFlags.Nullable));
6108
+ }
6109
+
6106
6110
/**
6107
6111
* Since the source of spread types are object literals, which are not binary,
6108
6112
* this function should be called in a left folding style, with left = previous result of getSpreadType
@@ -6114,7 +6118,7 @@ namespace ts {
6114
6118
}
6115
6119
6116
6120
if (left.flags & TypeFlags.Union) {
6117
- const types = filter(( <UnionType>left).types, t => !(t.flags & TypeFlags.Nullable) );
6121
+ const types = filterNulableTypes( <UnionType>left);
6118
6122
if (types.length) {
6119
6123
return getUnionType(map(types, t => getSpreadType(t, right, isFromObjectLiteral)));
6120
6124
}
@@ -6127,7 +6131,7 @@ namespace ts {
6127
6131
}
6128
6132
6129
6133
if (right.flags & TypeFlags.Union) {
6130
- const types = filter(( <UnionType>right).types, t => !(t.flags & TypeFlags.Nullable) );
6134
+ const types = filterNulableTypes( <UnionType>right);
6131
6135
if (types.length) {
6132
6136
return getUnionType(map(types, t => getSpreadType(left, t, isFromObjectLiteral)));
6133
6137
}
0 commit comments