Skip to content

TypeScript typings are swallowed for most of the components #1758

Closed
@yamafaktory

Description

@yamafaktory

🐛 Bug Report

Hi folks 👋,

First of all, thanks for the massive work done on this project!

Back to the bug report: there's an issue with TypeScript's types for most of the components. It seems like React.forwardRef is the culprit here.

🤔 Expected Behavior

All the components should expose their types correctly - i.e. no any.

😯 Current Behavior

For example, the following View component - when imported - is inferred as any:

image

https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/view/src/View.tsx#L45

Whereas a Button works totally fine:

image

https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/button/src/Button.tsx#L96

💁 Possible Solution

Enforce proper types exposition (via aliasing).

🔦 Context

I encountered that while using React Spectrum in production project.

💻 Code Sample

Not relevant.

🌍 Your Environment

Software Version(s)
react-spectrum 3.9.0
typescript 4.2.3
Browser not relevant
Operating System not relevant

🧢 Your Company/Team

Not relevant.

🕷 Tracking Issue (optional)

None.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions