react-spectrum: Missing attributes inside Button distribution
š Bug Report
Iām working in our company monorepo and was adding some type checking to it. I initially thought it must be user error, but I dug a little deeper and noticed the types in the button distribution are missing imports. I can see they should be defined in (as they are in the repository), but in my node_modules they are not.
Hereās what Iām seeing inside node_modules/@react-aria/button/dist/types.d.ts:
import { ElementType, HTMLAttributes, RefObject } from "react";
import { AriaButtonProps, AriaToggleButtonProps } from "@react-types/button";
...
export function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
tsc fails because of missing AnchorHTMLAttributes
, this pattern repeats forButtonHTMLAttributes
and alsoInputHTMLAttributes
.
š¤ Expected Behavior
Button.d.ts should be importing the missing attributes (my editor suggested the following):
import {AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, HTMLAttributes, InputHTMLAttributes, RefObject } from "react";
šÆ Current Behavior
They donāt exist, it is only happening inside Button which is interesting.
The error is self-explanatory but: ../../node_modules/@react-aria/button/dist/types.d.ts:11:108 - error TS2304: Cannot find name 'ButtonHTMLAttributes'.
š Possible Solution
Whatever is generating the import needs adjusting.
š¦ Context
Working with tsc.
š» Code Sample
I double and tripled checked through this just to be certain.
I found a way to show the problem: If we download the tarball from NPM: https://registry.npmjs.org/@react-aria/button/-/button-3.3.0.tgz
Open up dist/types.d.ts, youāll see the missing imports.
š Your Environment
Software | Version(s) |
---|---|
react-aria | ^3.1.1 |
Browser | N/A |
Operating System | Mac |
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 11
- Comments: 18 (12 by maintainers)
This should be released with todayās release, let us know if the issue still occurs. Iāve looked at the https://registry.npmjs.org/@react-aria/button/-/button-3.4.0.tgz tarball myself and verified that
AnchorHTMLAttributes
,ButtonHTMLAttributes
, andInputHTMLAttributes
now exist in thedist/types.d.ts
.Yep, itās still in there. Our automated release script didnāt notice because it wasnāt a code change and we humans forgot about it. Iāve been working on a script to catch this is the future. Weāll have it in our next release.
Ah, weāre probably missing these because we have to use --skipLibcheck in some other contexts. Seems reasonable. Weāre focused on a pretty big issue with pointer events this week, so soonest weād probably look at this is next week, just to set expectations.
Hopefully we can make some progress on this in December
Iāve opened a PR that should fix this on Parcelās end. I see that this repo hasnāt been keeping up with the nightlies and still has patches for parcelās library code. Should I update the patch for
@parcel/transformer-typescript-types
in a separate PR here or should we attempt to move to a more recent version of parcel?I took a deep look into this - the problem is in Parcel, and Iāve tracked down the issue to here: https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/typescript-types/src/TSModule.js#L39-L44
If you set a breakpoint there, youāll see that the node for
useButton
is overwritten for each declaration. @devongovett sorry to tag you here, is this something youād be able to look at? I havenāt gotten very far into learning TypeScriptās compiler API but Iām slowly working towards a fix.Is there an updated estimate on this? Weāre using
react-aria
to build a component library at our company, and this is causing issues for our consumers who donāt want to use--skipLibCheck
. Weād also rather not downgrade@react-aria/button
orreact-aria
(which depends on@react-aria/button@^3.3.2
).