Home / Function/ mapType() — react Function Reference

mapType() — react Function Reference

Architecture documentation for the mapType() function in TypeUtils.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d530521b_d20e_08a8_4bec_1170867678c4["mapType()"]
  1fccc28d_09ce_cbd9_cc1b_5224a1b90f93["TypeUtils.ts"]
  d530521b_d20e_08a8_4bec_1170867678c4 -->|defined in| 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93
  5b033808_ef9f_1c72_998b_14de0ddb4423["substitute()"]
  5b033808_ef9f_1c72_998b_14de0ddb4423 -->|calls| d530521b_d20e_08a8_4bec_1170867678c4
  30ec2474_aaf0_f8e7_9820_34b266dc18e0["unsupportedLanguageFeature()"]
  d530521b_d20e_08a8_4bec_1170867678c4 -->|calls| 30ec2474_aaf0_f8e7_9820_34b266dc18e0
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  d530521b_d20e_08a8_4bec_1170867678c4 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  style d530521b_d20e_08a8_4bec_1170867678c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Flood/TypeUtils.ts lines 57–143

export function mapType<T, U>(
  f: (t: T) => U,
  type: ConcreteType<T>,
): ConcreteType<U> {
  switch (type.kind) {
    case 'Mixed':
    case 'Number':
    case 'String':
    case 'Boolean':
    case 'Void':
      return type;

    case 'Nullable':
      return {
        kind: 'Nullable',
        type: f(type.type),
      };

    case 'Array':
      return {
        kind: 'Array',
        element: f(type.element),
      };

    case 'Set':
      return {
        kind: 'Set',
        element: f(type.element),
      };

    case 'Map':
      return {
        kind: 'Map',
        key: f(type.key),
        value: f(type.value),
      };

    case 'Function':
      return {
        kind: 'Function',
        typeParameters:
          type.typeParameters?.map(param => ({
            id: param.id,
            name: param.name,
            bound: f(param.bound),
          })) ?? null,
        params: type.params.map(f),
        returnType: f(type.returnType),
      };

    case 'Component': {
      return {
        kind: 'Component',
        children: type.children != null ? f(type.children) : null,
        props: new Map([...type.props.entries()].map(([k, v]) => [k, f(v)])),
      };
    }

    case 'Generic':
      return {
        kind: 'Generic',
        id: type.id,
        bound: f(type.bound),
      };

    case 'Object':
      return type;

    case 'Tuple':
      return {
        kind: 'Tuple',
        id: type.id,
        members: type.members.map(f),
      };

    case 'Structural':
      return type;

    case 'Enum':
    case 'Union':
    case 'Instance':

Domain

Subdomains

Called By

Frequently Asked Questions

What does mapType() do?
mapType() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Flood/TypeUtils.ts.
Where is mapType() defined?
mapType() is defined in compiler/packages/babel-plugin-react-compiler/src/Flood/TypeUtils.ts at line 57.
What does mapType() call?
mapType() calls 2 function(s): assertExhaustive, unsupportedLanguageFeature.
What calls mapType()?
mapType() is called by 1 function(s): substitute.

Analyze Your Own Codebase

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

Try Supermodel Free