Home / File/ ValidateHooksUsage.ts — react Source File

ValidateHooksUsage.ts — react Source File

Architecture documentation for ValidateHooksUsage.ts, a typescript file in the react codebase. 23 imports, 0 dependents.

File typescript BabelCompiler Validation 23 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  0aa1377a_e69b_36ae_b83d_c842baa2ad42["ValidateHooksUsage.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1["CompilerErrorDetail"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> 7cb692eb_ba8e_04dc_5f67_df48b332c3c1
  a2b91621_58d3_1d04_4663_00cd808f1034["ErrorCategory"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> a2b91621_58d3_1d04_4663_00cd808f1034
  c0d1dc03_8683_01ed_b02a_b10aae366514["ComputeUnconditionalBlocks.ts"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> c0d1dc03_8683_01ed_b02a_b10aae366514
  cc92da6a_36c2_147e_624d_3b9a7d1999b0["computeUnconditionalBlocks"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> cc92da6a_36c2_147e_624d_3b9a7d1999b0
  1b971013_8a90_0d8d_1fcc_f31581cd66aa["Environment.ts"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> 1b971013_8a90_0d8d_1fcc_f31581cd66aa
  c32c4801_8f1e_6ab5_ff15_ac8ec7df6945["isHookName"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> c32c4801_8f1e_6ab5_ff15_ac8ec7df6945
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> 18a78965_f593_105b_e5e8_07001321c2ec
  9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> 9241c5c1_a9a7_17bc_e41c_e967225008dd
  e3a6ca26_1f1a_c7f8_fbf3_804737192775["IdentifierId"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> e3a6ca26_1f1a_c7f8_fbf3_804737192775
  c7aaa235_c19e_3530_31c2_911f38eed3e0["Place"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> c7aaa235_c19e_3530_31c2_911f38eed3e0
  12f5fb24_c07f_2c87_0f50_a3ec7dde7aa4["SourceLocation"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> 12f5fb24_c07f_2c87_0f50_a3ec7dde7aa4
  9cbd2355_05cd_5bbd_253f_7aeb4f947484["getHookKind"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> 9cbd2355_05cd_5bbd_253f_7aeb4f947484
  style 0aa1377a_e69b_36ae_b83d_c842baa2ad42 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import * as t from '@babel/types';
import {
  CompilerError,
  CompilerErrorDetail,
  ErrorCategory,
} from '../CompilerError';
import {computeUnconditionalBlocks} from '../HIR/ComputeUnconditionalBlocks';
import {isHookName} from '../HIR/Environment';
import {
  HIRFunction,
  IdentifierId,
  Place,
  SourceLocation,
  getHookKind,
} from '../HIR/HIR';
import {
  eachInstructionLValue,
  eachInstructionOperand,
  eachTerminalOperand,
} from '../HIR/visitors';
import {assertExhaustive} from '../Utils/utils';
import {Result} from '../Utils/Result';

/**
 * Represents the possible kinds of value which may be stored at a given Place during
 * abstract interpretation. The kinds form a lattice, with earlier items taking
 * precedence over later items (see joinKinds()).
 */
enum Kind {
  // A potential/known hook which was already used in an invalid way
  Error = 'Error',

  /*
   * A known hook. Sources include:
   * - LoadGlobal instructions whose type was inferred as a hook
   * - PropertyLoad, ComputedLoad, and Destructuring instructions
   *   where the object is a KnownHook
   * - PropertyLoad, ComputedLoad, and Destructuring instructions
   *   where the object is a Global and the property name is hook-like
   */
  KnownHook = 'KnownHook',

  /*
   * A potential hook. Sources include:
   * - LValues (other than LoadGlobal) where the name is hook-like
   * - PropertyLoad, ComputedLoad, and Destructuring instructions
   *   where the object is a potential hook or the property name
   *   is hook-like
   */
  PotentialHook = 'PotentialHook',

  // LoadGlobal values whose type was not inferred as a hook
  Global = 'Global',
// ... (406 more lines)

Domain

Subdomains

Types

Frequently Asked Questions

What does ValidateHooksUsage.ts do?
ValidateHooksUsage.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ValidateHooksUsage.ts?
ValidateHooksUsage.ts defines 3 function(s): joinKinds, validateHooksUsage, visitFunctionExpression.
What does ValidateHooksUsage.ts depend on?
ValidateHooksUsage.ts imports 23 module(s): CompilerError, CompilerError.ts, CompilerErrorDetail, ComputeUnconditionalBlocks.ts, Environment.ts, ErrorCategory, HIR.ts, HIRFunction, and 15 more.
Where is ValidateHooksUsage.ts in the architecture?
ValidateHooksUsage.ts is located at compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateHooksUsage.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Validation).

Analyze Your Own Codebase

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

Try Supermodel Free