AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

SWC 56 Skips React Compiler For .Ts Files With Bare Generic Arrow Functions

Next.js 16.2.1 with SWC 56 fails to compile .ts files containing generic arrow functions with bare type parameters (e.g., <T>), causing React Compiler to skip entire files and silently drop memoization.

highConfidence 85%Next.jsRoute HandlersReact Server ComponentsServer ActionsAffected V16.2.0-Canary.42Affected V16.2.1

Origin Analysis

The SWC 56 upgrade changed parser defaults, causing isReactCompilerRequired() in Next.js to treat bare <T> in .ts files as JSX, leading to parse failure or misidentification, and the file is skipped for React Compiler processing. This is due to missing explicit tsx: false for .ts files when parsing with SWC.
1. Create a .ts file with a generic arrow function using bare <T> (no trailing comma, no default): ```ts // app/useMyHook.ts import { useState } from 'react'; const useMyHook = <T>(initialValue: T) => { const [value, setValue] = useState(initialValue); return { setValue, value }; }; export default useMyHook; ``` 2. Enable React Compiler: reactCompiler: true in next.config.mjs 3. bun dev, open the page, inspect .next/dev/static/chunks/ for the chunk containing useMyHook Result: useMyHook is NOT compiled — useState is called directly, no compiler-runtime import, no memo cache.

Fixing Code Block

Edge Case Audit

This fix may increase compilation time for .ts files due to AST traversal; but it's acceptable. Rollback: revert to original isReactCompilerRequired implementation. Ensure the function is used consistently across build and dev. Potential edge: if a .ts file contains JSX syntax (invalid), the parser will now throw, whereas before it might have been tolerated; but such files are already invalid TypeScript. Also ensure the regex for hook names doesn't miss custom hooks with unusual naming (though custom hooks should start with 'use').

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state