import UnionType from '../types/UnionType' ; import MantaStyle from '..' ; import NeverKeyword from '../types/NeverKeyword' ; import { resolveReferencedType } from './referenceTypes' ; import { Type } from '@manta-style/core' ; export function normalizeUnion ( unionType ) { const types = unionType . getTypes ( ) . map ( ( type ) => resolveReferencedType ( type ) . type ) . filter ( ( type ) => ! ( type instanceof NeverKeyword ) ) ; const { length } = types ; if ( length === 0 ) { return MantaStyle . NeverKeyword ; } else if ( length === 1 ) { return types [ 0 ] ; } else { return new UnionType ( types ) ; } }