Skip to content

Commit

Permalink
🐛 Fix hoisted mcdoc types losing their attributes (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
misode authored Dec 27, 2024
1 parent 7a9f1ae commit eba142e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/mcdoc/src/binder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,10 @@ function convertEnum(node: EnumNode, ctx: McdocBinderContext): McdocType {

// Return reference if the enum has been hoisted
if (identifier && !ctx.isHoisting) {
return { kind: 'reference', path: `${ctx.moduleIdentifier}::${identifier.value}` }
return wrapType(node, {
kind: 'reference',
path: `${ctx.moduleIdentifier}::${identifier.value}`,
}, ctx)
}

// Shortcut if the typeDef has been added to the enum symbol.
Expand Down Expand Up @@ -894,7 +897,10 @@ function convertStruct(node: StructNode, ctx: McdocBinderContext): McdocType {

// Return reference if the struct has been hoisted
if (identifier && !ctx.isHoisting) {
return { kind: 'reference', path: `${ctx.moduleIdentifier}::${identifier.value}` }
return wrapType(node, {
kind: 'reference',
path: `${ctx.moduleIdentifier}::${identifier.value}`,
}, ctx)
}

// Shortcut if the typeDef has been added to the struct symbol.
Expand Down

0 comments on commit eba142e

Please sign in to comment.