TypeUtils.ts — react Source File
Architecture documentation for TypeUtils.ts, a typescript file in the react codebase. 12 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93["TypeUtils.ts"] 0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 0423f759_97e0_9101_4634_ed555abc5ca9 eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> eb9d33f9_42c1_205c_93e6_8e1365a31839 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> d7fde76c_4fd9_feb3_299b_798689f05bc6 8086dd94_cb7f_b871_d873_325159c25b69["TypeErrors.ts"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 8086dd94_cb7f_b871_d873_325159c25b69 30ec2474_aaf0_f8e7_9820_34b266dc18e0["unsupportedLanguageFeature"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 30ec2474_aaf0_f8e7_9820_34b266dc18e0 912702ee_f06e_77d9_d237_a41c50607cdf["Types.ts"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 912702ee_f06e_77d9_d237_a41c50607cdf 8bfd3bfd_e96b_b673_4e8c_44097af26df2["ConcreteType"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 8bfd3bfd_e96b_b673_4e8c_44097af26df2 356ba0e3_3c35_6c18_303c_576df2a228fe["ResolvedType"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 356ba0e3_3c35_6c18_303c_576df2a228fe 0e66f60c_25c0_5202_291f_e9470ef3e748["TypeParameter"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 0e66f60c_25c0_5202_291f_e9470ef3e748 2d8606fb_bd77_8a0c_ac4d_57d0af3d046b["TypeParameterId"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 2d8606fb_bd77_8a0c_ac4d_57d0af3d046b c0b647d9_982f_2dc6_de63_c350aa5665d4["printConcrete"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> c0b647d9_982f_2dc6_de63_c350aa5665d4 38999144_d544_edc0_6efe_18d9bf834ada["printType"] 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 --> 38999144_d544_edc0_6efe_18d9bf834ada style 1fccc28d_09ce_cbd9_cc1b_5224a1b90f93 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import {GeneratedSource} from '../HIR';
import {assertExhaustive} from '../Utils/utils';
import {unsupportedLanguageFeature} from './TypeErrors';
import {
ConcreteType,
ResolvedType,
TypeParameter,
TypeParameterId,
DEBUG,
printConcrete,
printType,
} from './Types';
export function substitute(
type: ConcreteType<ResolvedType>,
typeParameters: Array<TypeParameter<ResolvedType>>,
typeArguments: Array<ResolvedType>,
): ResolvedType {
const substMap = new Map<TypeParameterId, ResolvedType>();
for (let i = 0; i < typeParameters.length; i++) {
// TODO: Length checks to make sure type params match up with args
const typeParameter = typeParameters[i];
const typeArgument = typeArguments[i];
substMap.set(typeParameter.id, typeArgument);
}
const substitutionFunction = (t: ResolvedType): ResolvedType => {
// TODO: We really want a stateful mapper or visitor here so that we can model nested polymorphic types
if (t.type.kind === 'Generic' && substMap.has(t.type.id)) {
const substitutedType = substMap.get(t.type.id)!;
return substitutedType;
}
return {
kind: 'Concrete',
type: mapType(substitutionFunction, t.type),
platform: t.platform,
};
};
const substituted = mapType(substitutionFunction, type);
if (DEBUG) {
let substs = '';
for (let i = 0; i < typeParameters.length; i++) {
const typeParameter = typeParameters[i];
const typeArgument = typeArguments[i];
substs += `[${typeParameter.name}${typeParameter.id} := ${printType(typeArgument)}]`;
}
console.log(
`${printConcrete(type, printType)}${substs} = ${printConcrete(substituted, printType)}`,
);
}
return {kind: 'Concrete', type: substituted, platform: /* TODO */ 'shared'};
}
export function mapType<T, U>(
f: (t: T) => U,
type: ConcreteType<T>,
): ConcreteType<U> {
// ... (253 more lines)
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does TypeUtils.ts do?
TypeUtils.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 TypeUtils.ts?
TypeUtils.ts defines 4 function(s): diff, filterOptional, mapType, substitute.
What does TypeUtils.ts depend on?
TypeUtils.ts imports 12 module(s): ConcreteType, ResolvedType, TypeErrors.ts, TypeParameter, TypeParameterId, Types.ts, assertExhaustive, index.ts, and 4 more.
Where is TypeUtils.ts in the architecture?
TypeUtils.ts is located at compiler/packages/babel-plugin-react-compiler/src/Flood/TypeUtils.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