Skip to content

fix: re-export DOMRenderProps and related types to fix downstream TS2742#9955

Open
lixiaoyan wants to merge 1 commit into
adobe:mainfrom
lixiaoyan:fix/rac-reexport-render-props-types
Open

fix: re-export DOMRenderProps and related types to fix downstream TS2742#9955
lixiaoyan wants to merge 1 commit into
adobe:mainfrom
lixiaoyan:fix/rac-reexport-render-props-types

Conversation

@lixiaoyan

Copy link
Copy Markdown
Contributor

Summary

Re-exports the RenderProps-related types from react-aria-components so downstream packages that emit their own .d.ts (composite TS projects, library dts builds, Storybook setups with declaration emit, etc.) can name the types reachable through RenderProps.

The v1.17.0 types refactor split the bundled dist/types.d.ts into per-source files. RenderProps extends StyleRenderProps extends DOMRenderProps, and StyleRenderProps['style'] uses StyleOrFunction — none of those names were publicly nameable from the package root. Downstream code that infers a type whose expansion crosses these names now fails with TS2742. Same family as #9775 (which was a TS4023 for TreeEmptyStateRenderProps).

Changes

  • packages/react-aria-components/src/utils.tsx — add export to StyleOrFunction (the only one of the six missing the keyword in source).
  • packages/react-aria-components/exports/index.ts — extend the type-only re-export from ../src/utils with DOMRenderProps, PossibleLinkDOMRenderProps, DOMRenderFunction, ClassNameOrFunction, StyleOrFunction, ChildrenOrFunction.

Type-only, additive — no runtime impact, no breaking change.

✅ Pull Request Checklist:

📝 Test Instructions:

Reproduction (before the fix)

In any downstream package that (a) wraps a RAC render-props type and (b) emits its own .d.ts:

// my-component.tsx
import {forwardRef} from 'react';
import type {RenderProps} from 'react-aria-components';

interface MyRenderValues {
  isPressed: boolean;
  isHovered: boolean;
}

// Wraps RAC's RenderProps — the typical pattern when building a component
// library on top of react-aria-components.
interface MyComponentProps extends RenderProps<MyRenderValues> {
  isDisabled?: boolean;
}

export const MyComponent = forwardRef<HTMLDivElement, MyComponentProps>(
  function MyComponent(_props, _ref) {
    return null;
  }
);
// my-component.stories.tsx
import type {Meta} from '@storybook/react';
import {MyComponent} from './my-component';

// `satisfies Meta<typeof MyComponent>` forces TS to materialize the
// inferred type of `default`, expanding through MyComponentProps →
// RenderProps → StyleRenderProps → DOMRenderProps, and through
// StyleRenderProps['style']: StyleOrFunction.
export default {
  title: 'MyComponent',
  component: MyComponent,
} satisfies Meta<typeof MyComponent>;

tsc (or any declaration emit) fails:

error TS2742: The inferred type of 'default' cannot be named without a
reference to '.../react-aria-components/dist/types/src/utils'. This is
likely not portable. A type annotation is necessary.

After

Type-checks and emits cleanly. The previously-unnameable names (DOMRenderProps, StyleOrFunction, etc.) are reachable via the package root, so TS can write portable declarations.

Why it worked in 1.16.0

The entire types surface lived in a single bundled dist/types.d.ts — every transitive name was reachable through that one file. The 1.17.0 per-file split made the missing public re-exports observable.

🧢 Your Project:

personal

@github-actions github-actions Bot added the RAC label Apr 21, 2026
reidbarber
reidbarber previously approved these changes Apr 22, 2026
@lixiaoyan lixiaoyan force-pushed the fix/rac-reexport-render-props-types branch from fdbcf01 to 39cba36 Compare June 9, 2026 14:51
fix downstream TS2742

The v1.17.0 types refactor split the bundled types.d.ts into per-source
files. RenderProps extends StyleRenderProps extends DOMRenderProps, and
StyleRenderProps['style'] uses StyleOrFunction — neither was publicly
nameable. Downstream packages built with composite/declaration emit then
fail with TS2742 on any inferred type whose expansion crosses these
names.

Adds `export` to StyleOrFunction and re-exports DOMRenderProps,
PossibleLinkDOMRenderProps, DOMRenderFunction, ClassNameOrFunction,
StyleOrFunction, and ChildrenOrFunction from the package entry.
Type-only,
additive — no runtime impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lixiaoyan lixiaoyan force-pushed the fix/rac-reexport-render-props-types branch from 39cba36 to 973e0f0 Compare June 9, 2026 14:53
@lixiaoyan lixiaoyan requested a review from reidbarber June 9, 2026 14:55
@lixiaoyan

Copy link
Copy Markdown
Contributor Author

@snowystinger Hi, any change to get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants