Home / File/ TypeErrors.ts — react Source File

TypeErrors.ts — react Source File

Architecture documentation for TypeErrors.ts, a typescript file in the react codebase. 8 imports, 2 dependents.

File typescript BabelCompiler Validation 8 imports 2 dependents 9 functions

Entity Profile

Dependency Diagram

graph LR
  8086dd94_cb7f_b871_d873_325159c25b69["TypeErrors.ts"]
  912702ee_f06e_77d9_d237_a41c50607cdf["Types.ts"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> 912702ee_f06e_77d9_d237_a41c50607cdf
  8bfd3bfd_e96b_b673_4e8c_44097af26df2["ConcreteType"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> 8bfd3bfd_e96b_b673_4e8c_44097af26df2
  c0b647d9_982f_2dc6_de63_c350aa5665d4["printConcrete"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> c0b647d9_982f_2dc6_de63_c350aa5665d4
  38999144_d544_edc0_6efe_18d9bf834ada["printType"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> 38999144_d544_edc0_6efe_18d9bf834ada
  321e0d91_23cf_cc89_de61_f0b32d318aab["StructuralValue"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> 321e0d91_23cf_cc89_de61_f0b32d318aab
  0670de12_28de_ef7e_e900_00f24fe326ad["Type"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> 0670de12_28de_ef7e_e900_00f24fe326ad
  c65f3587_3b96_56f7_cc32_0bd9849ecec0["VariableId"]
  8086dd94_cb7f_b871_d873_325159c25b69 --> c65f3587_3b96_56f7_cc32_0bd9849ecec0
  2ed45bcd_6c82_3ccd_0e20_fa96b5111055[".."]
  8086dd94_cb7f_b871_d873_325159c25b69 --> 2ed45bcd_6c82_3ccd_0e20_fa96b5111055
  1fccc28d_09ce_cbd9_cc1b_5224a1b90f93["TypeUtils.ts"]
  1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 8086dd94_cb7f_b871_d873_325159c25b69
  912702ee_f06e_77d9_d237_a41c50607cdf["Types.ts"]
  912702ee_f06e_77d9_d237_a41c50607cdf --> 8086dd94_cb7f_b871_d873_325159c25b69
  style 8086dd94_cb7f_b871_d873_325159c25b69 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {CompilerError, SourceLocation} from '..';
import {
  ConcreteType,
  printConcrete,
  printType,
  StructuralValue,
  Type,
  VariableId,
} from './Types';

export function unsupportedLanguageFeature(
  desc: string,
  loc: SourceLocation,
): never {
  CompilerError.throwInvalidJS({
    reason: `Typedchecker does not currently support language feature: ${desc}`,
    loc,
  });
}

export type UnificationError =
  | {
      kind: 'TypeUnification';
      left: ConcreteType<Type>;
      right: ConcreteType<Type>;
    }
  | {
      kind: 'StructuralUnification';
      left: StructuralValue;
      right: ConcreteType<Type>;
    };

function printUnificationError(err: UnificationError): string {
  if (err.kind === 'TypeUnification') {
    return `${printConcrete(err.left, printType)} is incompatible with ${printConcrete(err.right, printType)}`;
  } else {
    return `structural ${err.left.kind} is incompatible with ${printConcrete(err.right, printType)}`;
  }
}

export function raiseUnificationErrors(
  errs: null | Array<UnificationError>,
  loc: SourceLocation,
): void {
  if (errs != null) {
    if (errs.length === 0) {
      CompilerError.invariant(false, {
        reason: 'Should not have array of zero errors',
        loc,
      });
    } else if (errs.length === 1) {
      CompilerError.throwInvalidJS({
        reason: `Unable to unify types because ${printUnificationError(errs[0])}`,
        loc,
      });
    } else {
      const messages = errs
        .map(err => `\t* ${printUnificationError(err)}`)
        .join('\n');
      CompilerError.throwInvalidJS({
// ... (72 more lines)

Domain

Subdomains

Frequently Asked Questions

What does TypeErrors.ts do?
TypeErrors.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 TypeErrors.ts?
TypeErrors.ts defines 9 function(s): cannotAddVoid, checkTypeArgumentArity, notAFunction, notAPolymorphicFunction, printUnificationError, raiseUnificationErrors, unresolvableTypeVariable, unsupportedLanguageFeature, unsupportedTypeAnnotation.
What does TypeErrors.ts depend on?
TypeErrors.ts imports 8 module(s): .., ConcreteType, StructuralValue, Type, Types.ts, VariableId, printConcrete, printType.
What files import TypeErrors.ts?
TypeErrors.ts is imported by 2 file(s): TypeUtils.ts, Types.ts.
Where is TypeErrors.ts in the architecture?
TypeErrors.ts is located at compiler/packages/babel-plugin-react-compiler/src/Flood/TypeErrors.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Flood).

Analyze Your Own Codebase

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

Try Supermodel Free