Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining React 19 types issues #2168

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading