Skip to content

Commit

Permalink
Merge pull request #2168 from reduxjs/feature/react-19-types
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed May 2, 2024
2 parents bfa3c36 + a752cc6 commit eec5f9b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -83,6 +83,7 @@
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/node": "^20.11.6",
"@types/prop-types": "^15.7.12",
"@types/react": "18.2.25",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
Expand Down
2 changes: 1 addition & 1 deletion test/components/Provider.spec.tsx
Expand Up @@ -169,7 +169,7 @@ describe('React', () => {
action.type === 'INC' ? state + 1 : state

const innerStore = createStore(reducer)
const innerMapStateToProps = vi.fn<TStateProps, [number]>((state) => ({
const innerMapStateToProps = vi.fn<[number], TStateProps>((state) => ({
count: state,
}))
class Inner extends Component<TStateProps> {
Expand Down
7 changes: 4 additions & 3 deletions test/typetests/connect-options-and-issues.tsx
Expand Up @@ -801,16 +801,17 @@ function testRef() {
ref={(ref: number) => {}}
></ConnectedForwardedFunctionalComponent>

// Should be able to use all refs including legacy string
const classLegacyRef: React.LegacyRef<ClassComponent> | undefined = undefined
// Should be able to use all refs (except legacy string refs, which go away in React 19)
const classLegacyRef: React.Ref<ClassComponent> | undefined = undefined
;<ConnectedClassComponent ref={classLegacyRef}></ConnectedClassComponent>
;<ConnectedClassComponent
ref={React.createRef<ClassComponent>()}
></ConnectedClassComponent>
;<ConnectedClassComponent
ref={(ref: ClassComponent) => {}}
></ConnectedClassComponent>
;<ConnectedClassComponent ref={''}></ConnectedClassComponent>
// TODO Can make this an expected error if we target React 19 exclusively
// ;<ConnectedClassComponent ref={''}></ConnectedClassComponent>
// ref type should be the typeof the wrapped component
;<ConnectedClassComponent
// @ts-expect-error
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Expand Up @@ -2362,6 +2362,13 @@ __metadata:
languageName: node
linkType: hard

"@types/prop-types@npm:^15.7.12":
version: 15.7.12
resolution: "@types/prop-types@npm:15.7.12"
checksum: 10/ac16cc3d0a84431ffa5cfdf89579ad1e2269549f32ce0c769321fdd078f84db4fbe1b461ed5a1a496caf09e637c0e367d600c541435716a55b1d9713f5035dfe
languageName: node
linkType: hard

"@types/react-dom@npm:^18.0.0":
version: 18.2.18
resolution: "@types/react-dom@npm:18.2.18"
Expand Down Expand Up @@ -7131,6 +7138,7 @@ __metadata:
"@testing-library/react": "npm:^14.1.2"
"@testing-library/react-hooks": "npm:^8.0.1"
"@types/node": "npm:^20.11.6"
"@types/prop-types": "npm:^15.7.12"
"@types/react": "npm:18.2.25"
"@types/use-sync-external-store": "npm:^0.0.3"
"@typescript-eslint/eslint-plugin": "npm:^6.17.0"
Expand Down

0 comments on commit eec5f9b

Please sign in to comment.