Skip to content

Commit f47e9f6

Browse files
committed
replace ReactElement with ReactElement<any> in some places, part 2
1 parent 3a2173a commit f47e9f6

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

packages/ui-calendar/src/Calendar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
261261
const { prevButton, nextButton } = this.renderMonthNavigationButtons()
262262

263263
const cloneButton = (
264-
button: ReactElement,
264+
button: ReactElement<any>,
265265
onClick?: (e: React.MouseEvent) => void
266266
) =>
267267
safeCloneElement(button, {
@@ -425,7 +425,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
425425
)
426426

427427
return childrenArr
428-
.reduce((days: ReactElement[][], day, i) => {
428+
.reduce((days: ReactElement<any>[][], day, i) => {
429429
const index = Math.floor(i / 7)
430430
if (!days[index]) days.push([])
431431
days[index].push(day)

packages/ui-drilldown/src/Drilldown/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,9 +1556,9 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
15561556
},
15571557
'aria-haspopup': this.props.role,
15581558
id: this._triggerId,
1559-
disabled: !!((trigger as ReactElement).props.disabled || disabled),
1559+
disabled: !!((trigger as ReactElement<any>).props.disabled || disabled),
15601560
'aria-disabled':
1561-
(trigger as ReactElement).props.disabled || disabled
1561+
(trigger as ReactElement<any>).props.disabled || disabled
15621562
? 'true'
15631563
: undefined
15641564
})}

packages/ui-table/src/Table/Head/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import { Component, Children, ContextType } from 'react'
25+
import { Component, Children, ContextType, type ReactElement } from 'react'
2626

2727
import { omitProps, callRenderProp } from '@instructure/ui-react-utils'
2828
import { SimpleSelect } from '@instructure/ui-simple-select'
@@ -65,7 +65,7 @@ static defaultProps = {
6565
const [firstRow] = Children.toArray(this.props.children) as RowChild[]
6666
let sortable = false
6767
if (firstRow && firstRow.props && firstRow.props.children) {
68-
Children.forEach(firstRow.props.children, (grandchild) => {
68+
Children.forEach(firstRow.props.children, (grandchild: ReactElement<any>) => {
6969
if (grandchild?.props?.onRequestSort) {
7070
sortable = true
7171
return
@@ -114,7 +114,7 @@ static defaultProps = {
114114
> = {}
115115
let selectedOption: TableColHeaderProps['id'] | undefined
116116
let count = 0
117-
Children.forEach(firstRow.props.children, (grandchild) => {
117+
Children.forEach(firstRow.props.children, (grandchild: ReactElement<any>) => {
118118
count += 1
119119
if (!grandchild?.props) return // grandchild can be false
120120
const { id, stackedSortByLabel, sortDirection, onRequestSort } =

packages/ui-table/src/Table/Row/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import { Component, Children, ContextType, isValidElement } from 'react'
25+
import { Component, Children, ContextType, isValidElement, type ReactElement } from 'react'
2626

2727
import { omitProps, safeCloneElement } from '@instructure/ui-react-utils'
2828
import { View } from '@instructure/ui-view'
@@ -84,7 +84,7 @@ class Row extends Component<TableRowProps> {
8484
.map((child, index) => {
8585
if (isValidElement(child)) {
8686
return safeCloneElement(child, {
87-
key: child.props.name,
87+
key: (child as ReactElement<any>).props.name,
8888
// Sent down for compatibility with custom components
8989
// TODO DEPRECATED, remove in v11
9090
isStacked,

packages/ui-table/src/Table/Row/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type TableRowOwnProps = {
3636
*
3737
* By default `Table.ColHeader` or `Table.RowHeader` or `Table.Cell`
3838
*/
39-
children?: React.ReactElement | React.ReactElement[]
39+
children?: React.ReactElement<any> | React.ReactElement<any>[]
4040

4141
/**
4242
* Controls the hover state of the row.

packages/ui-table/src/Table/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import { Component, Children, isValidElement } from 'react'
25+
import { Component, Children, isValidElement, ReactElement } from 'react'
2626

2727
import { safeCloneElement, omitProps } from '@instructure/ui-react-utils'
2828
import { View } from '@instructure/ui-view'
@@ -92,9 +92,9 @@ class Table extends Component<TableProps> {
9292
getHeaders() {
9393
const [headChild] = Children.toArray(this.props.children)
9494
if (!headChild || !isValidElement(headChild)) return undefined
95-
const [firstRow] = Children.toArray(headChild.props.children)
95+
const [firstRow] = Children.toArray((headChild as ReactElement<any>).props.children)
9696
if (!firstRow || !isValidElement(firstRow)) return undefined
97-
return Children.map(firstRow.props.children, (colHeader) => {
97+
return Children.map((firstRow as ReactElement<any>).props.children, (colHeader) => {
9898
if (!isValidElement<{ children?: any }>(colHeader)) return undefined
9999
return colHeader.props.children
100100
})
@@ -132,7 +132,7 @@ class Table extends Component<TableProps> {
132132
)}
133133
{Children.map(children, (child) => {
134134
if (isValidElement(child)) {
135-
return safeCloneElement(child, { key: child.props.name })
135+
return safeCloneElement(child, { key: (child as ReactElement<any>).props.name })
136136
}
137137
return child
138138
})}

packages/ui-tabs/src/Tabs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class Tabs extends Component<TabsProps, TabsState> {
390390
if (activePanel !== undefined) {
391391
// cloning active panel with a proper custom key as a workaround because
392392
// safeCloneElement overwrites it with the key from the original element
393-
activePanelClone = cloneElement(activePanel as ReactElement, {
393+
activePanelClone = cloneElement(activePanel as ReactElement<any>, {
394394
key: `panel-${index}`
395395
})
396396

0 commit comments

Comments
 (0)