Home / Function/ getPropertyType() — react Function Reference

getPropertyType() — react Function Reference

Architecture documentation for the getPropertyType() function in Environment.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  628fae4b_1807_dcbc_24d1_59d8ce7820a2["getPropertyType()"]
  cba0c8a2_0db5_48e2_0d19_b2c6a46799e8["Environment"]
  628fae4b_1807_dcbc_24d1_59d8ce7820a2 -->|defined in| cba0c8a2_0db5_48e2_0d19_b2c6a46799e8
  17e4ff3c_e626_9c9b_1534_00488fccdf5c["getGlobalDeclaration()"]
  17e4ff3c_e626_9c9b_1534_00488fccdf5c -->|calls| 628fae4b_1807_dcbc_24d1_59d8ce7820a2
  041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"]
  628fae4b_1807_dcbc_24d1_59d8ce7820a2 -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e
  c32c4801_8f1e_6ab5_ff15_ac8ec7df6945["isHookName()"]
  628fae4b_1807_dcbc_24d1_59d8ce7820a2 -->|calls| c32c4801_8f1e_6ab5_ff15_ac8ec7df6945
  style 628fae4b_1807_dcbc_24d1_59d8ce7820a2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts lines 1182–1213

  getPropertyType(
    receiver: Type,
    property: string | number,
  ): BuiltInType | PolyType | null {
    let shapeId = null;
    if (receiver.kind === 'Object' || receiver.kind === 'Function') {
      shapeId = receiver.shapeId;
    }
    if (shapeId !== null) {
      /*
       * If an object or function has a shapeId, it must have been assigned
       * by Forget (and be present in a builtin or user-defined registry)
       */
      const shape = this.#shapes.get(shapeId);
      CompilerError.invariant(shape !== undefined, {
        reason: `[HIR] Forget internal error: cannot resolve shape ${shapeId}`,
        loc: GeneratedSource,
      });
      if (typeof property === 'string') {
        return (
          shape.properties.get(property) ??
          shape.properties.get('*') ??
          (isHookName(property) ? this.#getCustomHookType() : null)
        );
      } else {
        return shape.properties.get('*') ?? null;
      }
    } else if (typeof property === 'string' && isHookName(property)) {
      return this.#getCustomHookType();
    }
    return null;
  }

Subdomains

Frequently Asked Questions

What does getPropertyType() do?
getPropertyType() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts.
Where is getPropertyType() defined?
getPropertyType() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts at line 1182.
What does getPropertyType() call?
getPropertyType() calls 2 function(s): invariant, isHookName.
What calls getPropertyType()?
getPropertyType() is called by 1 function(s): getGlobalDeclaration.

Analyze Your Own Codebase

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

Try Supermodel Free