Translate null correctly when it is a part of a union type

master
Vitaliy Filippov 2019-10-23 17:00:38 +03:00
parent e5afdbcb58
commit 6fe28de2dc
1 changed files with 2 additions and 2 deletions

View File

@ -103,13 +103,13 @@ function convertType(fund: Fund, type: ?Type): Schema {
};
case 'union':
const enumerate = wu(type.variants)
.filter(variant => variant.kind === 'literal')
.filter(variant => variant.kind === 'literal' && variant.value !== null)
.map(literal => (literal: $FlowFixMe).value)
.tap(value => invariant(value !== undefined))
.toArray();
const schemas = wu(type.variants)
.filter(variant => variant.kind !== 'literal')
.filter(variant => variant.kind !== 'literal' || variant.value === null)
.map(variant => convert(fund, variant))
.toArray();