1
- import React , { Fragment } from 'react' ;
1
+ import React , { ComponentType , Fragment } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
3
import { flexRender } from '@tanstack/react-table' ;
4
4
import { render } from '@testing-library/react' ;
@@ -16,7 +16,7 @@ import {
16
16
useMockTestRowData ,
17
17
useTestHookCall ,
18
18
} from '../utils/testHookCalls.testutils' ;
19
- import { Table , TableProps } from '..' ;
19
+ import { ExpandedContentProps , Table , TableProps } from '..' ;
20
20
21
21
import ExpandedContent from './ExpandedContent' ;
22
22
@@ -60,7 +60,6 @@ const RowWithExpandableContent = (args: TableProps<Person>) => {
60
60
} ) }
61
61
</ Row >
62
62
) }
63
- { /* @ts -expect-error FIXME: ExpandedContent is incorrectly generic */ }
64
63
{ isExpandedContent && < ExpandedContent row = { row } /> }
65
64
</ Fragment >
66
65
) ;
@@ -129,12 +128,15 @@ describe('packages/table/Row/ExpandableContent', () => {
129
128
const { result } = renderHook ( ( ) => useMockTestRowData ( ) ) ;
130
129
const mockRow = result . current . firstRow ;
131
130
132
- const StyledExpandedContent = styled ( ExpandedContent ) `
131
+ // type assertion is needed in R17 with R16 types(@types/react 16.9.56)
132
+ // styled is not preserving the required row prop
133
+ const StyledExpandedContent = styled (
134
+ ExpandedContent as ComponentType < ExpandedContentProps < any > > ,
135
+ ) `
133
136
color: #69ffc6;
134
- ` ;
137
+ ` as typeof ExpandedContent ;
135
138
136
139
const { getByTestId } = render (
137
- // @ts -expect-error ExpandedContent is incorrectly generic FIXME:
138
140
< StyledExpandedContent row = { mockRow } data-testid = "styled" /> ,
139
141
) ;
140
142
@@ -149,14 +151,17 @@ describe('packages/table/Row/ExpandableContent', () => {
149
151
const { result } = renderHook ( ( ) => useMockTestRowData ( ) ) ;
150
152
const mockRow = result . current . firstRow ;
151
153
152
- const StyledExpandedContent = styled ( ExpandedContent ) < StyledProps > `
154
+ // type assertion is needed in R17 with R16 types(@types/react 16.9.56)
155
+ // styled is not preserving the required row prop
156
+ const StyledExpandedContent = styled (
157
+ ExpandedContent as ComponentType < ExpandedContentProps < any > > ,
158
+ ) < StyledProps > `
153
159
color: ${ props => props . color } ;
154
- ` ;
160
+ ` as typeof ExpandedContent ;
155
161
156
162
const { getByTestId } = render (
157
163
< StyledExpandedContent
158
164
data-testid = "styled"
159
- // @ts -expect-error ExpandedContent is incorrectly generic FIXME:
160
165
row = { mockRow }
161
166
color = "#69ffc6"
162
167
/> ,
@@ -175,15 +180,9 @@ describe('packages/table/Row/ExpandableContent', () => {
175
180
< >
176
181
{ /* @ts -expect-error - row is missing */ }
177
182
< ExpandedContent />
178
-
179
- { /* @ts -expect-error - ExpandedContent is incorrectly generic */ }
180
183
< ExpandedContent row = { firstRow } />
181
- { /* @ts -expect-error - ExpandedContent is incorrectly generic */ }
182
184
< ExpandedContent row = { firstRow } ref = { ref } />
183
-
184
- { /* @ts -expect-error - ExpandedContent is incorrectly generic */ }
185
185
< ExpandedContent row = { firstRow } virtualRow = { firstVirtualRow } />
186
- { /* @ts -expect-error - ExpandedContent is incorrectly generic */ }
187
186
< ExpandedContent row = { firstRow } virtualRow = { firstVirtualRow } ref = { ref } />
188
187
</ > ;
189
188
} ) ;
0 commit comments