Skip to content

Commit 4dede01

Browse files
authored
Update react types (#5237)
* Update Typescript and react types, use our own Key type
1 parent 66c2850 commit 4dede01

File tree

176 files changed

+762
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+762
-358
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = {
5353
}, {
5454
files: ['**/test/**', '**/stories/**', '**/docs/**', '**/chromatic/**', '**/__tests__/**'],
5555
rules: {
56+
'rsp-rules/no-react-key': [ERROR],
5657
'rsp-rules/act-events-test': ERROR,
5758
'rsp-rules/no-getByRole-toThrow': ERROR,
5859
'rulesdir/imports': OFF,
@@ -182,7 +183,8 @@ module.exports = {
182183
'react-hooks/exhaustive-deps': WARN,
183184

184185
// custom rules
185-
'rulesdir/sort-imports': [ERROR],
186+
'rsp-rules/no-react-key': [ERROR],
187+
'rsp-rules/sort-imports': [ERROR],
186188
'rulesdir/imports': [ERROR],
187189
'rulesdir/useLayoutEffectRule': [ERROR],
188190
'rulesdir/pure-render': [ERROR],

examples/rsp-cra-18/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function App() {
4646
{(item: any) =>
4747
(<Row key={item.foo} UNSTABLE_childItems={item.childRows}>
4848
{(key) => {
49-
return <Cell>{item[key.toString()]}</Cell>;
49+
return <Cell>{item[key]}</Cell>;
5050
}}
5151
</Row>)
5252
}

examples/rsp-cra-18/src/Journal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {Key} from 'react'
1+
import {Key} from '@react-types/shared';
22

33
interface Journal{
4-
rate: Key,
5-
description: string,
4+
rate: Key,
5+
description: string,
66
id: number
77
}
88

9-
export default Journal
9+
export default Journal

examples/rsp-cra-18/src/JournalEntries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function JournalEntries(props : {list : Journal[]}){
66
const element = props.list.map(item => (
77
<li key={item.id}>
88
<Divider size="M" marginTop="size-200" marginBottom="size-300" />
9-
<p>Your day was: {item.rate.toString()} </p>
9+
<p>Your day was: {item.rate} </p>
1010
<p>{item.description}</p>
1111
</li>
1212

examples/rsp-next-ts-17/components/Section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33

44
interface SectionProps {
55
title: string;
6-
children: JSX.Element | JSX.Element[];
6+
children: React.JSX.Element | React.JSX.Element[];
77
}
88

99
export default function Section(props: SectionProps) {

examples/rsp-next-ts/components/Section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33

44
interface SectionProps {
55
title: string;
6-
children: JSX.Element | JSX.Element[];
6+
children: React.JSX.Element | React.JSX.Element[];
77
}
88

99
export default function Section(props: SectionProps) {

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"copyrights": "babel-node --presets @babel/env ./scripts/addHeaders.js",
3434
"build:icons": "babel-node --presets @babel/env ./scripts/buildIcons.js",
3535
"clean:icons": "babel-node --presets @babel/env ./scripts/cleanIcons.js",
36-
"postinstall": "yarn build:icons && patch-package",
36+
"postinstall": "patch-package && yarn build:icons",
3737
"plop": "plop --plopfile scripts/plopfile.js",
3838
"chromatic": "NODE_ENV=production CHROMATIC=1 chromatic --project-token $CHROMATIC_PROJECT_TOKEN --build-script-name 'build:chromatic'",
3939
"chromatic:forced-colors": "NODE_ENV=production CHROMATIC=1 chromatic --project-token $CHROMATIC_FC_PROJECT_TOKEN --build-script-name 'build:chromatic-fc'",
@@ -98,10 +98,10 @@
9898
"@testing-library/jest-dom": "^5.16.5",
9999
"@testing-library/react": "^14.0.0",
100100
"@testing-library/user-event": "^14.4.3",
101-
"@types/react": "^18.2.7",
101+
"@types/react": "^18.2.28",
102102
"@types/storybook__react": "^5.2.1",
103-
"@typescript-eslint/eslint-plugin": "^5.40.0",
104-
"@typescript-eslint/parser": "^5.40.0",
103+
"@typescript-eslint/eslint-plugin": "^6.7.5",
104+
"@typescript-eslint/parser": "^6.7.5",
105105
"autoprefixer": "^9.6.0",
106106
"axe-core": "^4.6.3",
107107
"axe-playwright": "^1.1.11",
@@ -169,7 +169,7 @@
169169
"tailwindcss": "^3.2.2",
170170
"tailwindcss-animate": "^1.0.7",
171171
"tempy": "^0.5.0",
172-
"typescript": "5.0.4",
172+
"typescript": "5.2.2",
173173
"typescript-strict-plugin": "^2.0.0",
174174
"verdaccio": "^5.13.0",
175175
"walk-object": "^4.0.0",
@@ -178,6 +178,7 @@
178178
},
179179
"resolutions": {
180180
"@babel/core": "7.12.10",
181+
"@types/react": "18.2.28",
181182
"postcss": "8.4.24",
182183
"postcss-custom-properties": "13.2.0",
183184
"postcss-import": "15.1.0",

packages/@react-aria/actiongroup/src/useActionGroupItem.ts

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

13-
import {DOMAttributes, FocusableElement} from '@react-types/shared';
14-
import {Key, RefObject, useEffect} from 'react';
13+
import {DOMAttributes, FocusableElement, Key} from '@react-types/shared';
1514
import {ListState} from '@react-stately/list';
1615
import {mergeProps, useEffectEvent} from '@react-aria/utils';
1716
import {PressProps} from '@react-aria/interactions';
17+
import {RefObject, useEffect} from 'react';
1818

1919
export interface AriaActionGroupItemProps {
2020
key: Key

packages/@react-aria/dnd/src/DragPreview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import {flushSync} from 'react-dom';
1515
import React, {RefObject, useImperativeHandle, useRef, useState} from 'react';
1616

1717
export interface DragPreviewProps {
18-
children: (items: DragItem[]) => JSX.Element
18+
children: (items: DragItem[]) => React.JSX.Element
1919
}
2020

2121
function DragPreview(props: DragPreviewProps, ref: RefObject<DragPreviewRenderer>) {
2222
let render = props.children;
23-
let [children, setChildren] = useState<JSX.Element>(null);
23+
let [children, setChildren] = useState<React.JSX.Element>(null);
2424
let domRef = useRef(null);
2525

2626
useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement) => void) => {

packages/@react-aria/dnd/src/useDraggableItem.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
import {AriaButtonProps} from '@react-types/button';
1414
import {clearGlobalDnDState, isInternalDropOperation, setDraggingKeys, useDragModality} from './utils';
1515
import {DraggableCollectionState} from '@react-stately/dnd';
16-
import {HTMLAttributes, Key} from 'react';
16+
import {HTMLAttributes} from 'react';
1717
// @ts-ignore
1818
import intlMessages from '../intl/*.json';
19+
import {Key} from '@react-types/shared';
1920
import {useDescription} from '@react-aria/utils';
2021
import {useDrag} from './useDrag';
2122
import {useLocalizedStringFormatter} from '@react-aria/i18n';

0 commit comments

Comments
 (0)