Home / Function/ getTypeName() — supabase Function Reference

getTypeName() — supabase Function Reference

Architecture documentation for the getTypeName() function in Reference.ui.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  bc75db67_fb40_f66d_14fc_535987ab4dbf["getTypeName()"]
  7b65e0e2_6465_ff88_8734_fd54e97395dc["ParamOrTypeDetails()"]
  7b65e0e2_6465_ff88_8734_fd54e97395dc -->|calls| bc75db67_fb40_f66d_14fc_535987ab4dbf
  0da3d3e3_1ace_0b81_9190_19ded8972320["ReturnTypeDetails()"]
  0da3d3e3_1ace_0b81_9190_19ded8972320 -->|calls| bc75db67_fb40_f66d_14fc_535987ab4dbf
  9b0a62ae_f37b_d415_810a_501aaf8b41ce["nameOrDefault()"]
  bc75db67_fb40_f66d_14fc_535987ab4dbf -->|calls| 9b0a62ae_f37b_d415_810a_501aaf8b41ce
  style bc75db67_fb40_f66d_14fc_535987ab4dbf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/docs/Reference.ui.tsx lines 591–641

function getTypeName(parameter: object): string {
  if (!('type' in parameter)) return ''

  if (typeof parameter.type === 'string') {
    return parameter.type
  }

  if (
    typeof parameter.type !== 'object' ||
    parameter.type === null ||
    !('type' in parameter.type)
  ) {
    return ''
  }

  const type = parameter.type

  switch (type.type) {
    case 'nameOnly':
      return nameOrDefault(type, '')
    case 'intrinsic':
      return nameOrDefault(type, '')
    case 'literal':
      return 'value' in type ? (type.value === null ? 'null' : `"${type.value as string}"`) : ''
    case 'record':
      // Needs an extra level of wrapping to fake the wrapping parameter
      // @ts-ignore
      return `Record<${getTypeName({ type: type.keyType })}, ${getTypeName({ type: type.valueType })}>`
    case 'object':
      return nameOrDefault(type, 'object')
    case 'function':
      return 'function'
    case 'promise':
      // Needs an extra level of wrapping to fake the wrapping parameter
      // @ts-ignore
      return `Promise<${getTypeName({ type: type.awaited })}>`
    case 'union':
      return 'One of the following options'
    case 'index signature':
      // Needs an extra level of wrapping to fake the wrapping parameter
      // @ts-ignore
      return `{ [key: ${getTypeName({ type: type.keyType })}]: ${getTypeName({ type: type.valueType })} }`
    case 'array':
      // Needs an extra level of wrapping to fake the wrapping parameter
      // @ts-ignore
      const innerType = getTypeName({ type: type.elemType })
      return innerType ? `Array<${innerType}>` : 'Array'
  }

  return ''
}

Subdomains

Frequently Asked Questions

What does getTypeName() do?
getTypeName() is a function in the supabase codebase.
What does getTypeName() call?
getTypeName() calls 1 function(s): nameOrDefault.
What calls getTypeName()?
getTypeName() is called by 2 function(s): ParamOrTypeDetails, ReturnTypeDetails.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free