-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: react types backwards compat #8099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8c89fa6
7308759
eccc320
0136c6a
44bdfb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
import clsx from 'clsx'; | ||
import {mergeProps} from '@react-aria/utils'; | ||
import React, {ReactElement, ReactNode} from 'react'; | ||
import React, {ReactElement} from 'react'; | ||
import {useFocusRing} from './useFocusRing'; | ||
|
||
export interface FocusRingProps { | ||
|
@@ -40,7 +40,7 @@ export interface FocusRingProps { | |
* Focus rings are visible only when the user is interacting with a keyboard, | ||
* not with a mouse, touch, or other input methods. | ||
*/ | ||
export function FocusRing(props: FocusRingProps): ReactNode { | ||
export function FocusRing(props: FocusRingProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these are the defaults for the generic arguments right? So you don't need to include them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'll double check, but for some reason our build previously expanded like this, so figured it was better to match that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok but that's not necessarily the right thing |
||
let {children, focusClass, focusRingClass} = props; | ||
let {isFocused, isFocusVisible, focusProps} = useFocusRing(props); | ||
let child = React.Children.only(children); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
import {isRTL} from './utils'; | ||
import {Locale, useDefaultLocale} from './useDefaultLocale'; | ||
import React, {ReactNode, useContext} from 'react'; | ||
import React, {JSX, ReactNode, useContext} from 'react'; | ||
|
||
export interface I18nProviderProps { | ||
/** Contents that should have the locale applied. */ | ||
|
@@ -26,7 +26,7 @@ const I18nContext = React.createContext<Locale | null>(null); | |
/** | ||
* Provides the locale for the application to all child components. | ||
*/ | ||
export function I18nProvider(props: I18nProviderProps): ReactNode { | ||
export function I18nProvider(props: I18nProviderProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {locale, children} = props; | ||
let defaultLocale = useDefaultLocale(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import {FocusableElement} from '@react-types/shared'; | |
import {mergeProps, useObjectRef, useSyncRef} from '@react-aria/utils'; | ||
import {PressProps} from './usePress'; | ||
import {PressResponderContext} from './context'; | ||
import React, {ForwardedRef, ReactNode, useContext, useEffect, useMemo, useRef} from 'react'; | ||
import React, {ForwardedRef, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react'; | ||
|
||
interface PressResponderProps extends PressProps { | ||
children: ReactNode | ||
|
@@ -56,7 +56,7 @@ export const PressResponder = React.forwardRef(({children, ...props}: PressRespo | |
); | ||
}); | ||
|
||
export function ClearPressResponder({children}: {children: ReactNode}): ReactNode { | ||
export function ClearPressResponder({children}: {children: ReactNode}): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let context = useMemo(() => ({register: () => {}}), []); | ||
return ( | ||
<PressResponderContext.Provider value={context}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
import {AriaLabelingProps, DOMProps} from '@react-types/shared'; | ||
// @ts-ignore | ||
import intlMessages from '../intl/*.json'; | ||
import React, {ReactNode} from 'react'; | ||
import React, {JSX} from 'react'; | ||
import {useLabels} from '@react-aria/utils'; | ||
import {useLocalizedStringFormatter} from '@react-aria/i18n'; | ||
import {VisuallyHidden} from '@react-aria/visually-hidden'; | ||
|
@@ -28,7 +28,7 @@ export interface DismissButtonProps extends AriaLabelingProps, DOMProps { | |
* users to dismiss a modal or popup when there is no visual | ||
* affordance to do so. | ||
*/ | ||
export function DismissButton(props: DismissButtonProps): ReactNode { | ||
export function DismissButton(props: DismissButtonProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {onDismiss, ...otherProps} = props; | ||
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/overlays'); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import React, {createContext, ReactNode, useContext} from 'react'; | ||
import React, {createContext, JSX, ReactNode, useContext} from 'react'; | ||
|
||
export interface PortalProviderProps { | ||
/** Should return the element where we should portal to. Can clear the context by passing null. */ | ||
|
@@ -26,7 +26,7 @@ export const PortalContext = createContext<PortalProviderContextValue>({}); | |
/** | ||
* Sets the portal container for all overlay elements rendered by its children. | ||
*/ | ||
export function UNSAFE_PortalProvider(props: PortalProviderProps): ReactNode { | ||
export function UNSAFE_PortalProvider(props: PortalProviderProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {getContainer} = props; | ||
let {getContainer: ctxGetContainer} = useUNSAFE_PortalContext(); | ||
return ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
*/ | ||
|
||
import {DOMAttributes} from '@react-types/shared'; | ||
import React, {AriaAttributes, ReactNode, useContext, useEffect, useMemo, useState} from 'react'; | ||
import React, {AriaAttributes, JSX, ReactNode, useContext, useEffect, useMemo, useState} from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import {useIsSSR} from '@react-aria/ssr'; | ||
import {useUNSAFE_PortalContext} from './PortalProvider'; | ||
|
@@ -37,7 +37,7 @@ const Context = React.createContext<ModalContext | null>(null); | |
* subtree from screen readers. This is done using React context in order to account for things | ||
* like portals, which can cause the React tree and the DOM tree to differ significantly in structure. | ||
*/ | ||
export function ModalProvider(props: ModalProviderProps): ReactNode { | ||
export function ModalProvider(props: ModalProviderProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {children} = props; | ||
let parent = useContext(Context); | ||
let [modalCount, setModalCount] = useState(0); | ||
|
@@ -101,7 +101,7 @@ function OverlayContainerDOM(props: ModalProviderProps) { | |
* if a modal or other overlay is opened. Only the top-most modal or | ||
* overlay should be accessible at once. | ||
*/ | ||
export function OverlayProvider(props: ModalProviderProps): ReactNode { | ||
export function OverlayProvider(props: ModalProviderProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return ( | ||
<ModalProvider> | ||
<OverlayContainerDOM {...props} /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
*/ | ||
|
||
import {FocusableElement, RefObject} from '@react-types/shared'; | ||
import React, {ReactNode, useRef} from 'react'; | ||
import React, {JSX, ReactNode, useRef} from 'react'; | ||
import {selectData} from './useSelect'; | ||
import {SelectState} from '@react-stately/select'; | ||
import {useFormReset} from '@react-aria/utils'; | ||
|
@@ -109,7 +109,7 @@ export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: Select | |
* Renders a hidden native `<select>` element, which can be used to support browser | ||
* form autofill, mobile form navigation, and native form submission. | ||
*/ | ||
export function HiddenSelect<T>(props: HiddenSelectProps<T>): ReactNode | null { | ||
export function HiddenSelect<T>(props: HiddenSelectProps<T>): JSX.Element | null { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {state, triggerRef, label, name, isDisabled} = props; | ||
let selectRef = useRef(null); | ||
let {containerProps, selectProps} = useHiddenSelect({...props, selectRef}, state, triggerRef); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
import {focusWithoutScrolling, isMac, isWebKit} from './index'; | ||
import {Href, LinkDOMProps, RouterOptions} from '@react-types/shared'; | ||
import {isFirefox, isIPad} from './platform'; | ||
import React, {createContext, DOMAttributes, ReactNode, useContext, useMemo} from 'react'; | ||
import React, {createContext, DOMAttributes, JSX, ReactNode, useContext, useMemo} from 'react'; | ||
|
||
interface Router { | ||
isNative: boolean, | ||
|
@@ -37,7 +37,7 @@ interface RouterProviderProps { | |
* A RouterProvider accepts a `navigate` function from a framework or client side router, | ||
* and provides it to all nested React Aria links to enable client side navigation. | ||
*/ | ||
export function RouterProvider(props: RouterProviderProps): ReactNode { | ||
export function RouterProvider(props: RouterProviderProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {children, navigate, useHref} = props; | ||
|
||
let ctx = useMemo(() => ({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
import {Direction} from '@react-types/shared'; | ||
import {LayoutInfo} from '@react-stately/virtualizer'; | ||
import React, {CSSProperties, ReactNode, useRef} from 'react'; | ||
import React, {CSSProperties, JSX, ReactNode, useRef} from 'react'; | ||
import {useLocale} from '@react-aria/i18n'; | ||
import {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem'; | ||
|
||
|
@@ -24,7 +24,7 @@ interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> { | |
children: ReactNode | ||
} | ||
|
||
export function VirtualizerItem(props: VirtualizerItemProps): ReactNode { | ||
export function VirtualizerItem(props: VirtualizerItemProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let {style, className, layoutInfo, virtualizer, parent, children} = props; | ||
let {direction} = useLocale(); | ||
let ref = useRef<HTMLDivElement | null>(null); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
import {DOMAttributes} from '@react-types/shared'; | ||
import {mergeProps} from '@react-aria/utils'; | ||
import React, {CSSProperties, JSXElementConstructor, ReactNode, useMemo, useState} from 'react'; | ||
import React, {CSSProperties, JSX, JSXElementConstructor, ReactNode, useMemo, useState} from 'react'; | ||
import {useFocusWithin} from '@react-aria/interactions'; | ||
|
||
export interface VisuallyHiddenProps extends DOMAttributes { | ||
|
@@ -86,7 +86,7 @@ export function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHidd | |
* VisuallyHidden hides its children visually, while keeping content visible | ||
* to screen readers. | ||
*/ | ||
export function VisuallyHidden(props: VisuallyHiddenProps): ReactNode { | ||
export function VisuallyHidden(props: VisuallyHiddenProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
let {children, elementType: Element = 'div', isFocusable, style, ...otherProps} = props; | ||
let {visuallyHiddenProps} = useVisuallyHidden(props); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import ChevronRightSmall from '@spectrum-icons/ui/ChevronRightSmall'; | |
import {classNames} from '@react-spectrum/utils'; | ||
import {FocusRing} from '@react-aria/focus'; | ||
import {mergeProps} from '@react-aria/utils'; | ||
import React, {Fragment, ReactNode, useRef} from 'react'; | ||
import React, {Fragment, JSX, useRef} from 'react'; | ||
import styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css'; | ||
import {useBreadcrumbItem} from '@react-aria/breadcrumbs'; | ||
import {useHover} from '@react-aria/interactions'; | ||
|
@@ -25,7 +25,7 @@ interface SpectrumBreadcrumbItemProps extends BreadcrumbItemProps { | |
isMenu?: boolean | ||
} | ||
|
||
export function BreadcrumbItem(props: SpectrumBreadcrumbItemProps): ReactNode { | ||
export function BreadcrumbItem(props: SpectrumBreadcrumbItemProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal type |
||
let { | ||
children, | ||
isCurrent, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ import {DOMProps, RefObject, StyleProps} from '@react-types/shared'; | |
import {HelpText} from '@react-spectrum/label'; | ||
// @ts-ignore | ||
import intlMessages from '../intl/*.json'; | ||
import React, {HTMLAttributes, JSX, ReactNode} from 'react'; | ||
import React, {HTMLAttributes, JSX} from 'react'; | ||
import styles from '@adobe/spectrum-css-temp/components/calendar/vars.css'; | ||
import {useDateFormatter, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n'; | ||
import {VisuallyHidden} from '@react-aria/visually-hidden'; | ||
|
@@ -38,7 +38,7 @@ interface CalendarBaseProps<T extends CalendarState | RangeCalendarState> extend | |
calendarRef: RefObject<HTMLDivElement | null> | ||
} | ||
|
||
export function CalendarBase<T extends CalendarState | RangeCalendarState>(props: CalendarBaseProps<T>): ReactNode { | ||
export function CalendarBase<T extends CalendarState | RangeCalendarState>(props: CalendarBaseProps<T>): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal type |
||
let { | ||
state, | ||
calendarProps, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import {CalendarDate, getDayOfWeek, isSameDay, isSameMonth, isToday} from '@inte | |
import {CalendarState, RangeCalendarState} from '@react-stately/calendar'; | ||
import {classNames} from '@react-spectrum/utils'; | ||
import {mergeProps} from '@react-aria/utils'; | ||
import React, {ReactNode, useRef} from 'react'; | ||
import React, {JSX, useRef} from 'react'; | ||
import styles from '@adobe/spectrum-css-temp/components/calendar/vars.css'; | ||
import {useFocusRing} from '@react-aria/focus'; | ||
import {useHover} from '@react-aria/interactions'; | ||
|
@@ -27,7 +27,7 @@ interface CalendarCellProps extends AriaCalendarCellProps { | |
firstDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | ||
} | ||
|
||
export function CalendarCell({state, currentMonth, firstDayOfWeek, ...props}: CalendarCellProps): ReactNode { | ||
export function CalendarCell({state, currentMonth, firstDayOfWeek, ...props}: CalendarCellProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal |
||
let ref = useRef<HTMLElement>(null); | ||
let { | ||
cellProps, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ import {CalendarPropsBase} from '@react-types/calendar'; | |
import {CalendarState, RangeCalendarState} from '@react-stately/calendar'; | ||
import {classNames} from '@react-spectrum/utils'; | ||
import {DOMProps, StyleProps} from '@react-types/shared'; | ||
import React, {ReactNode} from 'react'; | ||
import React, {JSX} from 'react'; | ||
import styles from '@adobe/spectrum-css-temp/components/calendar/vars.css'; | ||
import {useCalendarGrid} from '@react-aria/calendar'; | ||
|
||
|
@@ -25,7 +25,7 @@ interface CalendarMonthProps extends CalendarPropsBase, DOMProps, StyleProps { | |
startDate: CalendarDate | ||
} | ||
|
||
export function CalendarMonth(props: CalendarMonthProps): ReactNode { | ||
export function CalendarMonth(props: CalendarMonthProps): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal |
||
let { | ||
state, | ||
startDate, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import {createCalendar} from '@internationalized/date'; | |
import {DatePickerSegment} from './DatePickerSegment'; | ||
import datepickerStyles from './styles.css'; | ||
import {DateValue, SpectrumDatePickerProps} from '@react-types/datepicker'; | ||
import React, {ReactNode, useRef} from 'react'; | ||
import React, {JSX, useRef} from 'react'; | ||
import {useDateField} from '@react-aria/datepicker'; | ||
import {useDateFieldState} from '@react-stately/datepicker'; | ||
import {useLocale} from '@react-aria/i18n'; | ||
|
@@ -26,7 +26,7 @@ interface DatePickerFieldProps<T extends DateValue> extends SpectrumDatePickerPr | |
maxGranularity?: SpectrumDatePickerProps<T>['granularity'] | ||
} | ||
|
||
export function DatePickerField<T extends DateValue>(props: DatePickerFieldProps<T>): ReactNode { | ||
export function DatePickerField<T extends DateValue>(props: DatePickerFieldProps<T>): JSX.Element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal |
||
let { | ||
isDisabled, | ||
isReadOnly, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why JSX.Element here but ReactElement in other places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some of these, unpkg was down, so I relied on the ts inference
this one is internal, so doesn't matter too much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, though it may have been inconsistent before as well. Just wondering which one we should use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've double checked all the old ones and included direct links to the previously generated output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including link to comment on type https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d2c29760d5939b14a41084d0154efbf45161bcfe/types/react/index.d.ts#L4005