Home / File/ CompilerError.ts — react Source File

CompilerError.ts — react Source File

Architecture documentation for CompilerError.ts, a typescript file in the react codebase. 10 imports, 60 dependents.

File typescript BabelCompiler Validation 10 imports 60 dependents 5 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 0423f759_97e0_9101_4634_ed555abc5ca9
  494e3425_0b47_293a_1ea4_d4670b0fc0e7["Result.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 494e3425_0b47_293a_1ea4_d4670b0fc0e7
  9217845a_d29d_c624_b607_e3b35cf604bc["Err"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 9217845a_d29d_c624_b607_e3b35cf604bc
  9f0e6a52_ff9e_00f3_1760_5fddfd89b234["Ok"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 9f0e6a52_ff9e_00f3_1760_5fddfd89b234
  7aace723_0ee1_cff5_b263_aec8e06dd79e["Result"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 7aace723_0ee1_cff5_b263_aec8e06dd79e
  eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> eb9d33f9_42c1_205c_93e6_8e1365a31839
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> d7fde76c_4fd9_feb3_299b_798689f05bc6
  52e3d8d7_abf4_7343_1f98_3f701ec04082["types"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 52e3d8d7_abf4_7343_1f98_3f701ec04082
  8121d90b_5e4d_09f2_e617_e1452a96fcb9["code-frame"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 8121d90b_5e4d_09f2_e617_e1452a96fcb9
  7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8["invariant"]
  e96f281e_f381_272d_2359_3e6a091c9a1d --> 7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8
  3acb56d9_57da_7e65_c06b_21b238146737["Gating.ts"]
  3acb56d9_57da_7e65_c06b_21b238146737 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  2a7e50cd_6171_085d_277c_6ced6ddd7148["Imports.ts"]
  2a7e50cd_6171_085d_277c_6ced6ddd7148 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  4828f3cc_e6ac_9239_d7f7_c05f7f60419c["Options.ts"]
  4828f3cc_e6ac_9239_d7f7_c05f7f60419c --> e96f281e_f381_272d_2359_3e6a091c9a1d
  9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"]
  9aa4477d_960b_1ea1_b6d9_36076aaa70bd --> e96f281e_f381_272d_2359_3e6a091c9a1d
  style e96f281e_f381_272d_2359_3e6a091c9a1d 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 {codeFrameColumns} from '@babel/code-frame';
import {type SourceLocation} from './HIR';
import {Err, Ok, Result} from './Utils/Result';
import {assertExhaustive} from './Utils/utils';
import invariant from 'invariant';

// Number of context lines to display above the source of an error
const CODEFRAME_LINES_ABOVE = 2;
// Number of context lines to display below the source of an error
const CODEFRAME_LINES_BELOW = 3;
/*
 * Max number of lines for the _source_ of an error, before we abbreviate
 * the display of the source portion
 */
const CODEFRAME_MAX_LINES = 10;
/*
 * When the error source exceeds the above threshold, how many lines of
 * the source should be displayed? We show:
 * - CODEFRAME_LINES_ABOVE context lines
 * - CODEFRAME_ABBREVIATED_SOURCE_LINES of the error
 * - '...' ellipsis
 * - CODEFRAME_ABBREVIATED_SOURCE_LINES of the error
 * - CODEFRAME_LINES_BELOW context lines
 *
 * This value must be at least 2 or else we'll cut off important parts of the error message
 */
const CODEFRAME_ABBREVIATED_SOURCE_LINES = 5;

export enum ErrorSeverity {
  /**
   * An actionable error that the developer can fix. For example, product code errors should be
   * reported as such.
   */
  Error = 'Error',
  /**
   * An error that the developer may not necessarily be able to fix. For example, syntax not
   * supported by the compiler does not indicate any fault in the product code.
   */
  Warning = 'Warning',
  /**
   * Not an error. These will not be surfaced in ESLint, but may be surfaced in other ways
   * (eg Forgive) where informational hints can be shown.
   */
  Hint = 'Hint',
  /**
   * These errors will not be reported anywhere. Useful for work in progress validations.
   */
  Off = 'Off',
}

export type CompilerDiagnosticOptions = {
  category: ErrorCategory;
// ... (1042 more lines)

Domain

Subdomains

Dependencies

Imported By

Frequently Asked Questions

What does CompilerError.ts do?
CompilerError.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 CompilerError.ts?
CompilerError.ts defines 5 function(s): LintRules, getRuleForCategory, getRuleForCategoryImpl, printCodeFrame, printErrorSummary.
What does CompilerError.ts depend on?
CompilerError.ts imports 10 module(s): Err, Ok, Result, Result.ts, assertExhaustive, code-frame, index.ts, invariant, and 2 more.
What files import CompilerError.ts?
CompilerError.ts is imported by 60 file(s): AliasingEffects.ts, AnalyseFunctions.ts, AssertConsistentIdentifiers.ts, AssertTerminalBlocksExist.ts, BuildHIR.ts, BuildReactiveFunction.ts, BuildReactiveScopeTerminalsHIR.ts, CodegenReactiveFunction.ts, and 52 more.
Where is CompilerError.ts in the architecture?
CompilerError.ts is located at compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src).

Analyze Your Own Codebase

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

Try Supermodel Free