Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix: omit `children` from XDSBaseProps — require explicit opt-in (#1246)

Joey67c630c59eed
diff --git a/packages/core/src/Collapsible/XDSCollapsible.tsx b/packages/core/src/Collapsible/XDSCollapsible.tsx
index fdf274e696..3e55610648 100644
--- a/packages/core/src/Collapsible/XDSCollapsible.tsx
+++ b/packages/core/src/Collapsible/XDSCollapsible.tsx
@@ -77,7 +77,7 @@ const styles = stylex.create({
},
});
-export interface XDSCollapsibleProps extends Omit<XDSBaseProps, 'children'> {
+export interface XDSCollapsibleProps extends XDSBaseProps {
/** Ref forwarded to the root element */
ref?: React.Ref<HTMLDivElement>;
/**
diff --git a/packages/core/src/Divider/XDSDivider.tsx b/packages/core/src/Divider/XDSDivider.tsx
index 12bbe236a4..b33e854aab 100644
--- a/packages/core/src/Divider/XDSDivider.tsx
+++ b/packages/core/src/Divider/XDSDivider.tsx
@@ -47,10 +47,7 @@ export interface XDSDividerVariantMap {
*/
export type XDSDividerVariant = keyof XDSDividerVariantMap;
-export interface XDSDividerProps extends Omit<
- XDSBaseProps<HTMLDivElement>,
- 'children'
-> {
+export interface XDSDividerProps extends XDSBaseProps<HTMLDivElement> {
/** Ref forwarded to the root element */
ref?: React.Ref<HTMLElement>;
/**
diff --git a/packages/core/src/MultiSelector/XDSMultiSelector.tsx b/packages/core/src/MultiSelector/XDSMultiSelector.tsx
index e3d1004243..b2abc6b071 100644
--- a/packages/core/src/MultiSelector/XDSMultiSelector.tsx
+++ b/packages/core/src/MultiSelector/XDSMultiSelector.tsx
@@ -353,7 +353,7 @@ export type {XDSMultiSelectorStatus};
export interface XDSMultiSelectorProps<
T extends XDSMultiSelectorOptionType = XDSMultiSelectorOptionType,
-> extends Omit<XDSBaseProps, 'onChange' | 'defaultValue' | 'children'> {
+> extends Omit<XDSBaseProps, 'onChange' | 'defaultValue'> {
/**
* Label text for the multi-selector (always rendered for accessibility).
*/
diff --git a/packages/core/src/Selector/XDSSelector.tsx b/packages/core/src/Selector/XDSSelector.tsx
index 74b6d3438b..496cc86fcb 100644
--- a/packages/core/src/Selector/XDSSelector.tsx
+++ b/packages/core/src/Selector/XDSSelector.tsx
@@ -275,7 +275,7 @@ export interface XDSSelectorStatus {
interface XDSSelectorPropsBase<
T extends XDSSelectorOptionType = XDSSelectorOptionType,
-> extends Omit<XDSBaseProps, 'onChange' | 'defaultValue' | 'children'> {
+> extends Omit<XDSBaseProps, 'onChange' | 'defaultValue'> {
/**
* Label text for the selector (always rendered for accessibility).
*/
diff --git a/packages/core/src/XDSBaseProps.ts b/packages/core/src/XDSBaseProps.ts
index 6b81f62802..7da4f42d79 100644
--- a/packages/core/src/XDSBaseProps.ts
+++ b/packages/core/src/XDSBaseProps.ts
@@ -4,10 +4,9 @@
* @output Exports XDSBaseProps — the shared base interface for all XDS components
* @position Type foundation; extended by all component prop interfaces
*
- * Starts with full HTMLAttributes and omits the handful of props that make
- * no sense on design system components. Consumers get drag-and-drop, pointer
- * events, keyboard handlers, clipboard events — everything they'd expect
- * from a DOM element, without contentEditable or dangerouslySetInnerHTML.
+ * Starts with full HTMLAttributes and omits props that should require
+ * intentional opt-in. `children` is excluded so slot-based components
+ * don't silently accept and drop JSX children at runtime.
*/
import type React from 'react';
@@ -16,12 +15,13 @@ import type {StyleXStyles} from '@stylexjs/stylex';
/**
* Base props shared by all XDS components.
*
- * Extends HTMLAttributes minus the genuinely irrelevant props. Components
- * extend this and re-declare common props with better JSDoc where useful
- * (e.g. Button re-declares onClick with its specific event type).
+ * Extends HTMLAttributes minus props that should be opt-in per component.
+ * `children` is omitted so slot-based components don't silently accept
+ * and drop JSX children; components that use children declare it explicitly.
*/
export interface XDSBaseProps<T extends HTMLElement = HTMLElement> extends Omit<
React.HTMLAttributes<T>,
+ | 'children'
| 'contentEditable'
| 'dangerouslySetInnerHTML'
| 'suppressContentEditableWarning'
diff --git a/packages/core/xds-core-0.0.11.tgz b/packages/core/xds-core-0.0.11.tgz
new file mode 100644
index 0000000000..caccec0638
Binary files /dev/null and b/packages/core/xds-core-0.0.11.tgz differ