Home / File/ bug-type-inference-control-flow.ts — react Source File

bug-type-inference-control-flow.ts — react Source File

Architecture documentation for bug-type-inference-control-flow.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
  4f18eebd_64d5_b1bc_e1f6_de520e717b3a["bug-type-inference-control-flow.ts"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  4f18eebd_64d5_b1bc_e1f6_de520e717b3a --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 4f18eebd_64d5_b1bc_e1f6_de520e717b3a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {arrayPush, CONST_NUMBER0, mutate} from 'shared-runtime';

/**
 * Repro for bug in our type inference system. We currently propagate inferred
 * types through control flow / potential type guards. Note that this is
 * inconsistent with both Flow and Typescript.
 * https://flow.org/try/#1N4Igxg9gdgZglgcxALlAIwIZoKYBsD6uEEAztvhgE6UYCe+JADpdhgCYowa5kA0I2KAFcAtiRQAXSkOz9sADwxgJ+NPTbYuQ3BMnTZA+Y2yU4IwRO4A6SFBIrGVDGM7c+h46fNRLuKxJIGWh8MeT0ZfhYlCStpHzNsFBAMIQkIEQwJODAQfiEyfBE4eWw2fDgofDBMsAALfAA3KjgsXGxxZC4eAw0G-GhcWn9aY3wWZldu-g1mbGqJUoBaCRHEzrcDEgBrbAk62kXhXFxJ923d-cPRHEpTgyEoMDaqZdW7vKgoOfaSKgOKpqmDA+d4gB5fMA-P6LCCMLLQbiLOoYCqgh6-GDYRYIXYLSgkRZkCR4jpddwPfJLZjpOBkO4AX34kA0SRWxgABAAxYjsgC87OAAB0oOzReythU2Mh2YKQNyILLeMKxeymrgZNLhCIbsL6QBuYVs7DsgBCVD5AuVYolUClMpAZsoiqtorVGvZWpuSqg9OFMAeyjg0HZdTmW3lAAp5NKAPJoABWcwkAEppWZGLg4O12fJ2bSuTyhSKxSwJEJKCKAOQ2tiVvMi3MAMkbOasNb5vP5svlsoNPuFfoD8JFGQqUel8vZAB9TVReCHoHa0MRnlBUwWIJbi6K4DB2RHbGxk1uVSrd-uAIShsDh4hR5PHoun5-siS1SgQADuHuw34AotQECUBGsqysmfYvuyvrbqepblg2EFitBKpwRWOZ9vSuQgA0JgkEGUBJBk9gmCA9JAA
 * https://www.typescriptlang.org/play/?#code/C4TwDgpgBAYg9nKBeKBvAUFLUDWBLAOwBMAuKAInjnIBpNsA3AQwBsBXCMgtgWwCMIAJ3QBfANzpQkKACEmg5GnpZ8xMuTmDayqM3aco3fkLoj0AMzYEAxsDxwCUawAsI1nFQAUADzJw+AFZuwACUZEwAzhFCwBFQ3lB4cVRK2InmUJ4AhJ4A5KpEuYmOCQBkpfEAdAXISCiUCOQhIalp2MDOgnAA7oYQvQCigl2CnuRWEN6QthBETTpmZhZWtvaOPEyEPmQpAD6y8jRODqRQfAgsEEwEYbAIrVh4GZ7WJy0Ybdgubh4IPiEST5YQQQYBsQQlQHYMxpEFgiHxCQiIA
 *
 * Found differences in evaluator results
 * Non-forget (expected):
 *   (kind: ok)
 *   [2]
 *   [3]
 * Forget:
 *   (kind: ok)
 *   [2]
 *   [2,3]
 */
function useFoo({cond, value}: {cond: boolean; value: number}) {
  const x = {value: cond ? CONST_NUMBER0 : []};
  mutate(x);

  const xValue = x.value;
  let result;
  if (typeof xValue === 'number') {
    result = xValue + 1; //               (1) here we infer xValue is a primitive
  } else {
    result = arrayPush(xValue, value); // (2) and propagate it to all other xValue references
  }

  return result;
}
export const FIXTURE_ENTRYPOINT = {
  fn: useFoo,
  params: [{cond: true}],
  sequentialRenders: [
    {cond: false, value: 2},
    {cond: false, value: 3},
  ],
};

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does bug-type-inference-control-flow.ts do?
bug-type-inference-control-flow.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 bug-type-inference-control-flow.ts?
bug-type-inference-control-flow.ts defines 1 function(s): useFoo.
What does bug-type-inference-control-flow.ts depend on?
bug-type-inference-control-flow.ts imports 1 module(s): shared-runtime.
Where is bug-type-inference-control-flow.ts in the architecture?
bug-type-inference-control-flow.ts is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-type-inference-control-flow.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