Skip to content

Commit 1e93060

Browse files
authored
refactor: Make it a TypeScript error to pass style macro to UNSAFE_className (#8109)
1 parent d46ae4c commit 1e93060

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/@react-spectrum/s2/src/ContextualHelp.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const ContextualHelp = forwardRef(function ContextualHelp(props: Contextu
103103
offset={offset}
104104
crossOffset={crossOffset}
105105
hideArrow
106-
UNSAFE_className={popover}>
106+
styles={popover}>
107107
<RACDialog className={mergeStyles(dialogInner, style({borderRadius: 'none', margin: -24, padding: 24}))}>
108108
<Provider
109109
values={[

packages/@react-spectrum/s2/src/style-utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ const heightProperties = [
186186
export type StylesProp = StyleString<(typeof allowedOverrides)[number] | (typeof widthProperties)[number]>;
187187
export type StylesPropWithHeight = StyleString<(typeof allowedOverrides)[number] | (typeof widthProperties)[number] | (typeof heightProperties)[number]>;
188188
export type StylesPropWithoutWidth = StyleString<(typeof allowedOverrides)[number]>;
189+
export type UnsafeClassName = string & {properties?: never};
189190
export interface UnsafeStyles {
190191
/** Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. */
191-
UNSAFE_className?: string,
192+
UNSAFE_className?: UnsafeClassName,
192193
/** Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. */
193194
UNSAFE_style?: CSSProperties
194195
}

0 commit comments

Comments
 (0)