import type { Breakpoint } from "@seed-design/css/breakpoints"; // Before: `T | { [K in Breakpoint]?: T }` // When T is an object (e.g. ButtonProps), union excess property check is weak // and allows mixing T's keys with Breakpoint keys without error. // The intersection with `never`-mapped keys forces TypeScript to reject the mix. type ResponsiveObject = { [K in Breakpoint]?: T } & (T extends object ? { [K in Exclude]?: never } : {}); export type ResponsiveValue = T | ResponsiveObject; export type UnwrapResponsive = T extends ResponsiveValue ? U : T; export type BreakpointThreshold = Exclude; export function isResponsiveObject(value: ResponsiveValue): value is ResponsiveObject { return typeof value === "object" && value !== null && !Array.isArray(value); }