Commit 2c548afd authored by Jude Gao's avatar Jude Gao

Add detection for non-serializable function props

Added warning section to flag when function types are passed as props
across server→client boundaries.

**Changes:**
- Track function props during type analysis
- Added functionProps array to PropsTypeInfo
- Display NON-SERIALIZABLE PROPS section in output
- Show prop name and value for each function prop

**Detection Logic:**
- Check if type has call signatures
- If yes, it's a function → non-serializable
- Track prop name in functionProps array

**Example Output:**
```
⚠️  NON-SERIALIZABLE PROPS DETECTED:
   - onClick = {handleClick} (function type)
   - y = {getUser} (function type)
```

This helps identify props that cannot be serialized and sent to
client components, which would cause runtime errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent b1130f03
...@@ -138,6 +138,18 @@ export function formatBoundaryAnalysis(analyzed: AnalyzedBoundary[]): string { ...@@ -138,6 +138,18 @@ export function formatBoundaryAnalysis(analyzed: AnalyzedBoundary[]): string {
lines.push(` - ${warning}`) lines.push(` - ${warning}`)
} }
} }
if (
boundary.propsType.functionProps &&
boundary.propsType.functionProps.length > 0
) {
lines.push(` ⚠️ NON-SERIALIZABLE PROPS DETECTED:`)
for (const funcProp of boundary.propsType.functionProps) {
const value = boundary.propsType.propValues[funcProp]
const propDetail = value ? `${funcProp} = {${value}}` : funcProp
lines.push(` - ${propDetail} (function type)`)
}
}
} else if (boundary.analysisError) { } else if (boundary.analysisError) {
lines.push(` ⚠️ Type analysis failed: ${boundary.analysisError}`) lines.push(` ⚠️ Type analysis failed: ${boundary.analysisError}`)
} }
......
...@@ -38,6 +38,11 @@ export interface PropsTypeInfo { ...@@ -38,6 +38,11 @@ export interface PropsTypeInfo {
*/ */
propValues: Record<string, string> propValues: Record<string, string>
/**
* List of non-serializable function props
*/
functionProps: string[]
/** /**
* Map tracking the source of each sensitive detection * Map tracking the source of each sensitive detection
* Key: full path like "credentials.password" * Key: full path like "credentials.password"
...@@ -141,6 +146,7 @@ export async function resolvePropsType( ...@@ -141,6 +146,7 @@ export async function resolvePropsType(
const propNames: string[] = [] const propNames: string[] = []
const propValues: Record<string, string> = {} const propValues: Record<string, string> = {}
const sensitiveSource: Record<string, string> = {} const sensitiveSource: Record<string, string> = {}
const functionProps: string[] = []
const typeParts: string[] = [] const typeParts: string[] = []
const sensitivePatterns = { const sensitivePatterns = {
...@@ -219,6 +225,7 @@ export async function resolvePropsType( ...@@ -219,6 +225,7 @@ export async function resolvePropsType(
console.log( console.log(
`[TYPE_RESOLVER] Warning: ${propName} is a function (non-serializable)` `[TYPE_RESOLVER] Warning: ${propName} is a function (non-serializable)`
) )
functionProps.push(propName)
} else if (isObjectType) { } else if (isObjectType) {
// OBJECT TYPE: Recursive type analysis // OBJECT TYPE: Recursive type analysis
// Source format: (propName=identifier).path // Source format: (propName=identifier).path
...@@ -344,6 +351,7 @@ export async function resolvePropsType( ...@@ -344,6 +351,7 @@ export async function resolvePropsType(
sensitiveFlags, sensitiveFlags,
sensitiveProps, sensitiveProps,
propValues, propValues,
functionProps,
sensitiveSource, sensitiveSource,
} }
} catch (error) { } catch (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment