mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Fix error with empty union
This commit is contained in:
@@ -286,6 +286,10 @@ function BooleanHead({ node, makeEdit }: Props) {
|
||||
function UnionHead({ type, optional, node, makeEdit, ctx }: Props<UnionType<SimplifiedMcdocTypeNoUnion>>) {
|
||||
const { locale } = useLocale()
|
||||
|
||||
if (type.members.length === 0) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
const selectedType = findSelectedMember(type, node)
|
||||
|
||||
const onSelect = useCallback((newValue: string) => {
|
||||
@@ -931,6 +935,9 @@ function getDefault(type: SimplifiedMcdocType, range: core.Range, ctx: McdocCont
|
||||
}
|
||||
}
|
||||
if (type.kind === 'union') {
|
||||
if (type.members.length === 0) {
|
||||
return { type: 'json:null', range }
|
||||
}
|
||||
return getDefault(type.members[0], range, ctx)
|
||||
}
|
||||
if (type.kind === 'enum') {
|
||||
|
||||
Reference in New Issue
Block a user