Skip to content

Commit

Permalink
More TypeDoc upgrade fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Dec 16, 2023
1 parent 52736a6 commit e817e86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/ui/components/TypeDocType/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ export const TypeDocType: FunctionComponent<TypeDocTypeProps> = ({

case 'reference':
// TODO: Get rid of it one TypeDoc adds it
const id = ((type as unknown) as { id: number }).id
const id = ((type as unknown) as { target: number }).target
const hash = inline.parentTypesMap?.[id] || typeHash(type.name, id)
const typeArguments = type.typeArguments
return (
<>
<>
{type.package ? <>{type.name}</> : <a href={hash}>{type.name}</a>}
{type.package !== 'date-fns' ? (
<>{type.name}</>
) : (
<a href={hash}>{type.name}</a>
)}

{typeArguments && '<'}
</>
Expand Down
18 changes: 9 additions & 9 deletions src/ui/screens/Docs/Doc/TypeDoc/Types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const useTypesModal = createModal<TypesModalProps>(
<div class={styles.header}>
<h2 class={styles.headerText}>
{type.name}
{type.kindString && (
{type.kind && (
<span class={styles.badge[kindToBadgeStyle(type.kind)]}>
{kindToBadgeTitle(type.kind)}
</span>
Expand Down Expand Up @@ -207,8 +207,8 @@ interface ContentProps {
}

function TypeContent({ type, scope }: ContentProps) {
switch (type.kindString) {
case 'Interface':
switch (type.kind) {
case DateFnsDocs.ReflectionKind.Interface:
if (!type.children?.length) return null

return (
Expand All @@ -218,7 +218,7 @@ function TypeContent({ type, scope }: ContentProps) {
</div>
)

case 'Type parameter':
case DateFnsDocs.ReflectionKind.TypeParameter:
return (
<div>
{
Expand Down Expand Up @@ -269,9 +269,9 @@ function extractTypes(
const types = acc || []

dec.children?.forEach((child) => {
switch (child.kindString) {
switch (child.kind) {
// Ignore these types and their children
case 'Function':
case DateFnsDocs.ReflectionKind.Function:
return

// // Process function singatures and add their type parameters
Expand All @@ -283,15 +283,15 @@ function extractTypes(
// return

// Add these types, but not process their children
case 'Interface':
case 'Type alias':
case DateFnsDocs.ReflectionKind.Interface:
case DateFnsDocs.ReflectionKind.TypeAlias:
// Ignore external, i.e. Record
if (child.flags.isExternal) return
types.push(child)
return

default:
console.log('~~~ UNHANDLED TYPE', child.kindString, child)
console.log('~~~ UNHANDLED TYPE', child.kind, child)
}

if (child.children) extractTypes(child, types)
Expand Down

0 comments on commit e817e86

Please sign in to comment.