990 matches across 25 files for func main lang:TypeScript
snippet_mode: auto · sorted by relevance
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts TYPESCRIPT 176 matches · showing 5 view file →
15} from '../CompilerError';
16import {CompileErrorDetail} from './Options';
17import {ExternalFunction, ReactFunctionType} from '../HIR/Environment';
18import {CodegenFunction} from '../ReactiveScopes';
19import {isComponentDeclaration} from '../Utils/ComponentDeclaration';
· · ·
18import {CodegenFunction} from '../ReactiveScopes';
19import {isComponentDeclaration} from '../Utils/ComponentDeclaration';
20import {isHookDeclaration} from '../Utils/HookDeclaration';
· · ·
21import {assertExhaustive} from '../Utils/utils';
22import {insertGatedFunctionDeclaration} from './Gating';
23import {
24 addImportsToProgram,
· · ·
34import {compileFn} from './Pipeline';
35import {
36 filterSuppressionsThatAffectFunction,
37 findProgramSuppressions,
38 suppressionsToCompilerError,
· · ·
51const DYNAMIC_GATING_DIRECTIVE = new RegExp('^use memo if\\(([^\\)]*)\\)$');
52
53export function tryFindDirectiveEnablingMemoization(
54 directives: Array<t.Directive>,
55 opts: ParsedPluginOptions,
+ 171 more matches in this file
packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts TYPESCRIPT 95 matches · showing 5 view file →
27 * character to exclude identifiers like "user".
28 */
29function isHookName(s: string): boolean {
30 return s === 'use' || /^use[A-Z0-9]/.test(s);
31}
· · ·
35 * containing a hook name.
36 */
37function isHook(node: Node): boolean {
38 if (node.type === 'Identifier') {
39 return isHookName(node.name);
· · ·
55 * always start with an uppercase letter.
56 */
57function isComponentName(node: Node): boolean {
58 return node.type === 'Identifier' && /^[A-Z]/.test(node.name);
59}
· · ·
60
61function isReactFunction(node: Node, functionName: string): boolean {
62 return (
63 ('name' in node && node.name === functionName) ||
· · ·
63 ('name' in node && node.name === functionName) ||
64 (node.type === 'MemberExpression' &&
65 'name' in node.object &&
+ 90 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts TYPESCRIPT 29 matches · showing 5 view file →
25} from './HIR';
26
27export function* eachInstructionLValue(
28 instr: ReactiveInstruction,
29): Iterable<Place> {
· · ·
34}
35
36export function* eachInstructionLValueWithKind(
37 instr: ReactiveInstruction,
38): Iterable<[Place, InstructionKind]> {
· · ·
60}
61
62export function* eachInstructionValueLValue(
63 value: ReactiveValue,
64): Iterable<Place> {
· · ·
83}
84
85export function* eachInstructionOperand(instr: Instruction): Iterable<Place> {
86 yield* eachInstructionValueOperand(instr.value);
87}
· · ·
88export function* eachInstructionValueOperand(
89 instrValue: InstructionValue,
90): Iterable<Place> {
+ 24 more matches in this file
compiler/scripts/test-internal-files.ts TYPESCRIPT 15 matches · showing 5 view file →
184];
185
186function walkDir(dir: string, callback: (filePath: string) => void): void {
187 let entries: fs.Dirent[];
188 try {
· · ·
202}
203
204function discoverFiles(): FileEntry[] {
205 console.log('Discovering files...');
206 const results: FileEntry[] = [];
· · ·
241
242// --- Build plugin options from production config ---
243function makePluginOptions(
244 projectConfig: Record<string, unknown>,
245 logger: {logEvent: (filename: string | null, event: LoggerEvent) => void},
· · ·
262
263// --- Compile a file ---
264function compileFile(
265 mode: 'ts' | 'rust',
266 filePath: string,
· · ·
295
296// --- Format events for comparison ---
297function formatEvents(events: LoggerEvent[]): string {
298 return events
299 .filter(e =>
+ 10 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateExhaustiveDependencies.ts TYPESCRIPT 51 matches · showing 5 view file →
21 FinishMemoize,
22 GeneratedSource,
23 HIRFunction,
24 Identifier,
25 IdentifierId,
· · ·
26 InstructionKind,
27 isEffectEventFunctionType,
28 isPrimitiveType,
29 isStableType,
· · ·
61 *
62 * The implementation compares the manual dependencies against the values
63 * actually used within the memoization function
64 * - For each value V referenced in the memo function, either:
65 * - If the value is non-reactive *and* a known stable type, then the
· · ·
64 * - For each value V referenced in the memo function, either:
65 * - If the value is non-reactive *and* a known stable type, then the
66 * value may optionally be specified as an exact dependency.
· · ·
71 * always cause the other path to change as well.
72 * - Any dependencies that do not correspond to a value referenced in the memo
73 * function are considered extraneous and throw an error
74 *
75 * ## TODO: Invalid, Complex Deps
+ 46 more matches in this file
compiler/packages/react-mcp-server/src/index.ts TYPESCRIPT 23 matches · showing 5 view file →
12import {
13 CompilerPipelineValue,
14 printReactiveFunctionWithOutlined,
15 printFunctionWithOutlined,
16 PluginOptions,
· · ·
15 printFunctionWithOutlined,
16 PluginOptions,
17 SourceLocation,
· · ·
24import {parseReactComponentTree} from './tools/componentTree';
25
26function calculateMean(values: number[]): string {
27 return values.length > 0
28 ? values.reduce((acc, curr) => acc + curr, 0) / values.length + 'ms'
· · ·
51 const content = pages.map(html => {
52 const $ = cheerio.load(html);
53 // react.dev should always have at least one <article> with the main content
54 const article = $('article').html();
55 if (article != null) {
· · ·
91 {
92 text: z.string(),
93 passName: z.enum(['HIR', 'ReactiveFunction', 'All', '@DEBUG']).optional(),
94 },
95 async ({text, passName}) => {
+ 18 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts TYPESCRIPT 77 matches · showing 5 view file →
34 BuiltInType,
35 Effect,
36 FunctionType,
37 GeneratedSource,
38 HIRFunction,
· · ·
38 HIRFunction,
39 IdentifierId,
40 NonLocalBinding,
· · ·
55 DefaultMutatingHook,
56 DefaultNonmutatingHook,
57 FunctionSignature,
58 ShapeRegistry,
59 addHook,
· · ·
65import {assertExhaustive} from '../Utils/utils';
66
67export const ExternalFunctionSchema = z.object({
68 // Source for the imported module that exports the `importSpecifierName` functions
69 source: z.string(),
· · ·
68 // Source for the imported module that exports the `importSpecifierName` functions
69 source: z.string(),
70
+ 72 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts TYPESCRIPT 115 matches · showing 5 view file →
14} from '../CompilerError';
15import {assertExhaustive} from '../Utils/utils';
16import {Environment, ReactFunctionType} from './Environment';
17import type {HookKind} from './ObjectShape';
18import {Type, makeType} from './Types';
· · ·
42
43/*
44 * A React function defines a computation that takes some set of reactive inputs
45 * (props, hook arguments) and return a result (JSX, hook return value). Unlike
46 * HIR, the data model is tree-shaped:
· · ·
47 *
48 * ReactFunction
49 * ReactiveBlock
50 * ReactiveBlockScope*
· · ·
57 * within that scope.
58 */
59export type ReactiveFunction = {
60 loc: SourceLocation;
61 id: ValidIdentifierName | null;
· · ·
167 | ReactiveTryTerminal;
168
169function _staticInvariantReactiveTerminalHasLocation(
170 terminal: ReactiveTerminal,
171): SourceLocation {
+ 110 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts TYPESCRIPT 96 matches · showing 5 view file →
28 GeneratedSource,
29 GotoVariant,
30 HIRFunction,
31 IfTerminal,
32 InstructionKind,
· · ·
33 InstructionValue,
34 JsxAttribute,
35 LoweredFunction,
36 ObjectPattern,
37 ObjectProperty,
· · ·
62
63/*
64 * Converts a function into a high-level intermediate form (HIR) which represents
65 * the code as a control-flow graph. All normal control-flow is modeled as accurately
66 * as possible to allow precise, expression-level memoization. The main exceptions are
· · ·
66 * as possible to allow precise, expression-level memoization. The main exceptions are
67 * try/catch statements and exceptions: we currently bail out (skip compilation) for
68 * try/catch and do not attempt to model control flow of exceptions, which can occur
· · ·
70 * the runtime, ie by invalidating memoization.
71 */
72export function lower(
73 func: NodePath<t.Function>,
74 env: Environment,
+ 91 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts TYPESCRIPT 44 matches · showing 5 view file →
80};
81
82function newBlock(id: BlockId, kind: BlockKind): WipBlock {
83 return {id, kind, instructions: []};
84}
· · ·
96 /*
97 * Mode used for code not covered by explicit exception handling, any
98 * errors are assumed to be thrown out of the function
99 */
100 | {kind: 'ThrowExceptions'}
· · ·
214 * Because Forget does not preserve _all_ block scopes in the input (only those that
215 * happen to occur from control flow), this resolution ensures that different variables
216 * with the same name are mapped to a unique name. Concretely, this function maintains
217 * the invariant that all references to a given variable will return an `Identifier`
218 * with the same (unique for the function) `name` and `id`.
· · ·
218 * with the same (unique for the function) `name` and `id`.
219 *
220 * Example:
· · ·
221 *
222 * ```javascript
223 * function foo() {
224 * const x = 0;
225 * {
+ 39 more matches in this file
compiler/packages/snap/src/runner.ts TYPESCRIPT 14 matches · showing 5 view file →
75};
76
77async function runTestCommand(opts: TestOptions): Promise<void> {
78 // Rust native module doesn't load in jest-worker child processes,
79 // so force sync mode when using the Rust backend.
· · ·
114 inputPath: './tmp.js',
115 input: `
116 function Foo(props) {
117 return identity(props);
118 }
· · ·
128 }
129 } else {
130 // Non-watch mode. For simplicity we re-use the same watchSrc() function.
131 // After the first build completes run tests and exit
132 const tsWatch: ts.WatchOfConfigFile<ts.SemanticDiagnosticsBuilderProgram> =
· · ·
183}
184
185async function runMinimizeCommand(opts: MinimizeOptions): Promise<void> {
186 // Resolve the input path
187 const inputPath = path.isAbsolute(opts.path)
· · ·
243}
244
245async function runMinimizeRustDeltaCommand(
246 opts: MinimizeRustDeltaOptions,
247): Promise<void> {
+ 9 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts TYPESCRIPT 23 matches · showing 5 view file →
14 Place,
15 ReactiveBlock,
16 ReactiveFunction,
17 ReactiveScope,
18 ReactiveScopeBlock,
· · ·
26import {
27 BuiltInArrayId,
28 BuiltInFunctionId,
29 BuiltInJsxId,
30 BuiltInObjectId,
· · ·
32import {eachInstructionLValue} from '../HIR/visitors';
33import {assertExhaustive, Iterable_some} from '../Utils/utils';
34import {printReactiveScopeSummary} from './PrintReactiveFunction';
35import {
36 ReactiveFunctionTransform,
· · ·
36 ReactiveFunctionTransform,
37 ReactiveFunctionVisitor,
38 Transformed,
· · ·
37 ReactiveFunctionVisitor,
38 Transformed,
39 visitReactiveFunction,
+ 18 more matches in this file
compiler/packages/babel-plugin-react-compiler/scripts/babel-plugin-annotate-react-code.ts TYPESCRIPT 45 matches · showing 5 view file →
10import * as t from '@babel/types';
11
12export default function AnnotateReactCodeBabelPlugin(
13 _babel: typeof BabelCore,
14): BabelCore.PluginObj {
· · ·
23}
24
25function annotate(program: NodePath<t.Program>): void {
26 function traverseFn(fn: BabelFn): void {
27 if (!shouldVisit(fn)) {
· · ·
26 function traverseFn(fn: BabelFn): void {
27 if (!shouldVisit(fn)) {
28 return;
· · ·
38
39 program.traverse({
40 FunctionDeclaration: traverseFn,
41 FunctionExpression: traverseFn,
42 ArrowFunctionExpression: traverseFn,
· · ·
41 FunctionExpression: traverseFn,
42 ArrowFunctionExpression: traverseFn,
43 });
+ 40 more matches in this file
compiler/scripts/test-e2e.ts TYPESCRIPT 14 matches · showing 5 view file →
74 : DEFAULT_FIXTURES_DIR;
75
76function discoverFixtures(rootPath: string): string[] {
77 const stat = fs.statSync(rootPath);
78 if (stat.isFile()) {
· · ·
81
82 const results: string[] = [];
83 function walk(dir: string): void {
84 for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
85 const fullPath = path.join(dir, entry.name);
· · ·
145// Reparse with Babel and regenerate with compact:true to erase all
146// whitespace/formatting differences, then Prettier for readable output.
147async function formatCode(code: string, isFlow: boolean): Promise<string> {
148 try {
149 const parserPlugins: string[] = isFlow
· · ·
174};
175
176function compileBabel(
177 plugin: any,
178 fixturePath: string,
· · ·
229const STRIP_KEYS = new Set(['identifierName', 'fnLoc']);
230
231function sortAndStrip(obj: unknown): unknown {
232 if (obj === null || typeof obj !== 'object') return obj;
233 if (Array.isArray(obj)) return obj.map(sortAndStrip);
+ 9 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts TYPESCRIPT 19 matches · showing 5 view file →
9import * as t from '@babel/types';
10import {CompilerDiagnostic, ErrorCategory} from '..';
11import {CodegenFunction} from '../ReactiveScopes';
12import {Environment} from '../HIR/Environment';
13
· · ·
32 * Note: For VariableDeclaration, VariableDeclarator, and Identifier, we enforce stricter validation
33 * that requires both the source location AND node type to match in the generated AST. This ensures
34 * that variable declarations maintain their structural integrity through compilation.
35 */
36const IMPORTANT_INSTRUMENTED_TYPES = new Set([
· · ·
37 'ArrowFunctionExpression',
38 'AssignmentPattern',
39 'ObjectMethod',
· · ·
54 'SwitchCase',
55 'WithStatement',
56 'FunctionDeclaration',
57 'FunctionExpression',
58 'LabeledStatement',
· · ·
57 'FunctionExpression',
58 'LabeledStatement',
59 'ConditionalExpression',
+ 14 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts TYPESCRIPT 8 matches · showing 5 view file →
523}
524
525export function printCodeFrame(
526 source: string,
527 loc: t.SourceLocation,
· · ·
563}
564
565function printErrorSummary(category: ErrorCategory, message: string): string {
566 let heading: string;
567 switch (category) {
· · ·
677 ErrorBoundaries = 'ErrorBoundaries',
678 /**
679 * Checking for pure functions
680 */
681 Purity = 'Purity',
· · ·
765const RULE_NAME_PATTERN = /^[a-z]+(-[a-z]+)*$/;
766
767export function getRuleForCategory(category: ErrorCategory): LintRule {
768 const rule = getRuleForCategoryImpl(category);
769 invariant(
· · ·
774}
775
776function getRuleForCategoryImpl(category: ErrorCategory): LintRule {
777 switch (category) {
778 case ErrorCategory.CapitalizedCalls: {
+ 3 more matches in this file
compiler/scripts/profile-rust-port.ts TYPESCRIPT 10 matches · showing 5 view file →
127
128// --- Discover fixtures ---
129function discoverFixtures(rootPath: string): string[] {
130 const results: string[] = [];
131 function walk(dir: string): void {
· · ·
131 function walk(dir: string): void {
132 for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
133 const fullPath = path.join(dir, entry.name);
· · ·
148
149// --- Compile fixture with TS compiler (no debug logging) ---
150function compileWithTS(fixturePath: string): number {
151 const source = fs.readFileSync(fixturePath, 'utf8');
152 const firstLine = source.substring(0, source.indexOf('\n'));
· · ·
188
189// --- Compile fixture with Rust compiler (profiled) ---
190function compileWithRustProfile(fixturePath: string): {
191 total_us: number;
192 scopeExtraction_us: number;
· · ·
213 plugins: [
214 // Use a minimal plugin that captures the AST and scope info
215 function capturePlugin(_api: typeof babel): babel.PluginObj {
216 return {
217 name: 'capture',
+ 5 more matches in this file
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts TYPESCRIPT 100 matches · showing 5 view file →
19 ErrorCategory,
20} from '../CompilerError';
21import {Environment, ExternalFunction} from '../HIR';
22import {
23 ArrayPattern,
· · ·
35 PrunedReactiveScopeBlock,
36 ReactiveBlock,
37 ReactiveFunction,
38 ReactiveInstruction,
39 ReactiveScope,
· · ·
54import {GuardKind} from '../Utils/RuntimeDiagnosticConstants';
55import {assertExhaustive} from '../Utils/utils';
56import {buildReactiveFunction} from './BuildReactiveFunction';
57import {SINGLE_CHILD_FBT_TAGS} from './MemoizeFbtAndMacroOperandsInSameScope';
58import {ReactiveFunctionVisitor, visitReactiveFunction} from './visitors';
· · ·
58import {ReactiveFunctionVisitor, visitReactiveFunction} from './visitors';
59import {ReactFunctionType} from '../HIR/Environment';
60import {ProgramContext} from '../Entrypoint';
· · ·
59import {ReactFunctionType} from '../HIR/Environment';
60import {ProgramContext} from '../Entrypoint';
61
+ 95 more matches in this file
compiler/scripts/test-rust-port.ts TYPESCRIPT 21 matches · showing 5 view file →
31import {parseConfigPragmaForTests} from '../packages/babel-plugin-react-compiler/src/Utils/TestUtils';
32import {printDebugHIR} from '../packages/babel-plugin-react-compiler/src/HIR/DebugPrintHIR';
33import {printDebugReactiveFunction} from '../packages/babel-plugin-react-compiler/src/HIR/DebugPrintReactiveFunction';
34import type {CompilerPipelineValue} from '../packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline';
35
· · ·
65
66// --- Ordered pass list (derived from pipeline.rs DebugLogEntry calls) ---
67function derivePassOrder(): string[] {
68 const pipelinePath = path.join(
69 REPO_ROOT,
· · ·
78
79// --- Detect last ported pass from pipeline.rs ---
80function detectLastPortedPass(): string {
81 if (PASS_ORDER.length === 0) {
82 throw new Error('No ported passes found in pipeline.rs');
· · ·
176
177// --- Discover fixtures ---
178function discoverFixtures(rootPath: string): string[] {
179 const stat = fs.statSync(rootPath);
180 if (stat.isFile()) {
· · ·
183
184 const results: string[] = [];
185 function walk(dir: string): void {
186 for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
187 const fullPath = path.join(dir, entry.name);
+ 16 more matches in this file
compiler/packages/react-forgive/client/src/colors.ts TYPESCRIPT 2 matches view file →
41 }
42 /**
43 * Redistributes rgb, maintaing hue until its clamped.
44 * https://stackoverflow.com/a/141943
45 */
· · ·
76];
77
78export function getColorFor(index: number): Color {
79 return COLOR_POOL[Math.abs(index) % COLOR_POOL.length]!;
80}
fixtures/flight-parcel/src/Todos.tsx TYPESCRIPT 3 matches view file →
8import {TodoList} from './TodoList';
9
10export async function Todos({id}: {id?: number}) {
11 return (
12 <html style={{colorScheme: 'dark light'}}>
· · ·
22 </Dialog>
23 </header>
24 <main>
25 <div className="todo-column">
26 <TodoList id={id} />
· · ·
27 </div>
28 {id != null ? <TodoDetail key={id} id={id} /> : <p>Select a todo</p>}
29 </main>
30 </body>
31 </html>
compiler/packages/react-compiler-healthcheck/src/index.ts TYPESCRIPT 2 matches view file →
14import strictModeCheck from './checks/strictMode';
15
16async function main() {
17 const argv = yargs(process.argv.slice(2))
18 .scriptName('healthcheck')
· · ·
54}
55
56main();
57
compiler/apps/playground/components/Logo.tsx TYPESCRIPT 2 matches view file →
6 */
7
8// https://github.com/reactjs/reactjs.org/blob/main/beta/src/components/Logo.tsx
9
10export default function Logo(props: JSX.IntrinsicElements['svg']): JSX.Element {
· · ·
10export default function Logo(props: JSX.IntrinsicElements['svg']): JSX.Element {
11 return (
12 <svg
compiler/packages/babel-plugin-react-compiler/src/Flood/FlowTypes.ts TYPESCRIPT 2 matches view file →
161 prefix?: string;
162 suffix?: string;
163 remainder?: FlowType;
164}
165
· · ·
543export type ThisStatus =
544 | {kind: 'This_Method'; unbound: boolean}
545 | {kind: 'This_Function'};
546
547// Effect types
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-multiple-fbt-plural.tsx TYPESCRIPT 4 matches view file →
11 * The root issue here is that fbt:plural/enum/pronoun read `.start` and `.end` from
12 * babel nodes to slice into source strings for some complex dedupe logic
13 * (see [_getStringVariationCombinations](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/JSFbtBuilder.js#L297))
14 *
15 *
· · ·
16 * Since Forget does not add `.start` and `.end` for babel nodes it synthesizes,
17 * [getRawSource](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/FbtUtil.js#L666-L673)
18 * simply returns the whole source code string. As a result, all fbt nodes dedupe together
19 * and _getStringVariationCombinations ends up early exiting (before adding valid candidate values).
· · ·
22 *
23 * For fbt:plural tags specifically, the `count` node require that a `.start/.end`
24 * (see [code in FbtPluralNode](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtPluralNode.js#L87-L90))
25 */
26function Foo({rewrites, months}) {
· · ·
26function Foo({rewrites, months}) {
27 return (
28 <fbt desc="Test fbt description">
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.