import { createContext, useContext, useState } from "react"; // --- Types --- interface ThemeContextValue { mode: "light" | "dark"; setMode: (mode: "light" | "dark") => void; } const ThemeContext = createContext(null); // --- Provider with React.ReactNode children --- function ThemeProvider({ children }: { children: React.ReactNode }) { const [mode, setMode] = useState<"light" | "dark">("light"); return ( {children} ); } // --- Component with mixed props (simple + React types) --- interface User { name: string; email: string; id: number; joinedAt: Date; } interface UserCardProps { user: User; role: "admin" | "editor" | "viewer"; permissions: string[]; onEdit: (id: number) => void; tags: Map; statusIndicator: React.ReactElement; actionBar?: React.ReactNode; } function UserCard({ user, role, permissions, onEdit, tags, statusIndicator, actionBar }: UserCardProps) { const [expanded, setExpanded] = useState(false); const theme = useContext(ThemeContext); return (
{user.name} ({role})
{user.email}
{permissions.join(", ")}
{statusIndicator}
{actionBar} {expanded && (
ID: {user.id}
)}
); } // --- Simple component (no React types) --- interface TodoItemProps { id: number; title: string; completed: boolean; priority: "low" | "medium" | "high"; onToggle: (id: number) => void; } function TodoItem({ id, title, completed, priority, onToggle }: TodoItemProps) { return (
onToggle(id)} /> {title} ({priority})
); } // --- Main sample app --- function SampleApp() { return (

Sample App (iframe)

console.log("edit", id)} tags={new Map([["verified", true]])} statusIndicator={Active} /> {}} />
); } export { ThemeProvider, ThemeContext, UserCard, TodoItem, SampleApp };