Home / File/ align-scopes-nested-block-structure.ts — react Source File

align-scopes-nested-block-structure.ts — react Source File

Architecture documentation for align-scopes-nested-block-structure.ts, a typescript file in the react codebase. 1 imports, 0 dependents.

File typescript TestingUtilities Fixtures 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  bd9ac8ed_630e_ab25_6a50_83a02143a85a["align-scopes-nested-block-structure.ts"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  bd9ac8ed_630e_ab25_6a50_83a02143a85a --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style bd9ac8ed_630e_ab25_6a50_83a02143a85a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {mutate} from 'shared-runtime';
/**
 * Fixture showing that it's not sufficient to only align direct scoped
 * accesses of a block-fallthrough pair.
 * Below is a simplified view of HIR blocks in this fixture.
 * Note that here, s is mutated in both bb1 and bb4. However, neither
 * bb1 nor bb4 have terminal fallthroughs or are fallthroughs themselves.
 *
 * This means that we need to recursively visit all scopes accessed between
 * a block and its fallthrough and extend the range of those scopes which overlap
 * with an active block/fallthrough pair,
 *
 *  bb0
 *  ┌──────────────┐
 *  │let s = null  │
 *  │test cond1    │
 *  │ <fallthr=bb3>│
 *  └┬─────────────┘
 *   │  bb1
 *   ├─►┌───────┐
 *   │  │s = {} ├────┐
 *   │  └───────┘    │
 *   │  bb2          │
 *   └─►┌───────┐    │
 *      │return;│    │
 *      └───────┘    │
 *  bb3              │
 *  ┌──────────────┐◄┘
 *  │test cond2    │
 *  │ <fallthr=bb5>│
 *  └┬─────────────┘
 *   │  bb4
 *   ├─►┌─────────┐
 *   │  │mutate(s)├─┐
 *   ▼  └─────────┘ │
 *  bb5             │
 *  ┌───────────┐   │
 *  │return s;  │◄──┘
 *  └───────────┘
 */
function useFoo({cond1, cond2}) {
  let s = null;
  if (cond1) {
    s = {};
  } else {
    return null;
  }

  if (cond2) {
    mutate(s);
  }

  return s;
}

export const FIXTURE_ENTRYPOINT = {
  fn: useFoo,
  params: [{cond1: true, cond2: false}],
  sequentialRenders: [
    {cond1: true, cond2: false},
    {cond1: true, cond2: false},
    {cond1: true, cond2: true},
    {cond1: true, cond2: true},
    {cond1: false, cond2: true},
  ],
};

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does align-scopes-nested-block-structure.ts do?
align-scopes-nested-block-structure.ts is a source file in the react codebase, written in typescript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in align-scopes-nested-block-structure.ts?
align-scopes-nested-block-structure.ts defines 1 function(s): useFoo.
What does align-scopes-nested-block-structure.ts depend on?
align-scopes-nested-block-structure.ts imports 1 module(s): shared-runtime.
Where is align-scopes-nested-block-structure.ts in the architecture?
align-scopes-nested-block-structure.ts is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/align-scopes-nested-block-structure.ts (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).

Analyze Your Own Codebase

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

Try Supermodel Free