Skip to content

Commit 63ddab7

Browse files
Add Types for Card (#2361)
* Add Types for Card * Update to match Item * Edit Card types to include forward ref Co-authored-by: Danni <[email protected]>
1 parent fa7fbb2 commit 63ddab7

File tree

1 file changed

+5
-8
lines changed
  • packages/@react-spectrum/card/src

1 file changed

+5
-8
lines changed

packages/@react-spectrum/card/src/Card.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
1413
import {CardBase} from './CardBase';
15-
import {DOMRef} from '@react-types/shared';
14+
import {DOMRef, DOMRefValue, ItemProps} from '@react-types/shared';
1615
import {PartialNode} from '@react-stately/collections';
17-
import React, {forwardRef} from 'react';
16+
import React, {forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes} from 'react';
1817
import {SpectrumCardProps} from '@react-types/card';
1918
import {useCardViewContext} from './CardViewContext';
2019

20+
2121
let Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) => {
2222
let context = useCardViewContext();
2323
if (context !== null) {
@@ -29,10 +29,8 @@ let Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) =>
2929
}
3030
});
3131

32-
// TODO: Update the typescript for the below and the export
3332
// @ts-ignore
34-
// eslint-disable-next-line
35-
Card.getCollectionNode = function* getCollectionNode<T>(props, context: any): Generator<PartialNode<T>> {
33+
Card.getCollectionNode = function* getCollectionNode<T>(props: any): Generator<PartialNode<T>> {
3634
let {children, textValue} = props;
3735

3836
yield {
@@ -45,6 +43,5 @@ Card.getCollectionNode = function* getCollectionNode<T>(props, context: any): Ge
4543
};
4644
};
4745

48-
// eslint-disable-next-line
49-
let _Card = Card as <T>(props, ref) => JSX.Element;
46+
let _Card = Card as ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & PropsWithoutRef<SpectrumCardProps> & RefAttributes<DOMRefValue<HTMLDivElement>>>;
5047
export {_Card as Card};

0 commit comments

Comments
 (0)